Adding to this ..... using lazy initialization can ensure the object
is only created when needed .... like this:
protected NSMutableDictionary _dynamicBindings;
public NSMutableDictionary dynamicBindings() {
if ( _dynamicBindings == null){
_dynamicBindings = new NSMutableDictionary();
}
return _dynamicBindings;
}
On Aug 16, 2007, at 11:06 AM, Steven Mark McCraw wrote:
> Hey David,
>
> You just create a NSMutableDictionary in a component that you
> subclass in all your "working" components. I call mine 'ph' (short
> for placeholder, in my mind) because I want it to be short since
> I'll be accessing it a lot.
>
> So you declare the variable in the superclass, create setters and
> getters for it, and then in the constructor do:
>
> setPh(new NSMutableDictionary());
>
> Now every time you need a variable to use as the "item" binding in
> a repetition, for example, you won't need to declare it in the
> component. You can just bind item to ph.whateverYouWantToCallIt
>
> If for some reason you need to reference it in your code elsewhere,
> you just say (MyClass)ph.valueForKey("whateverYouWantToCallIt"). I
> find that if you're going to be accessing it in your code a lot,
> this becomes a pain, so for those variables, I go ahead and declare
> local ivars and accessors.
>
> Mark
>
>
> On Aug 16, 2007, at 10:59 AM, David Avendasora wrote:
>
>> This idea intrigues me. Can you explain further? Would this be a
>> good "Best Practice" to follow?
>>
>> I will put all this in the WOProject/WOLips/Tutorials/Editing
>> WOComponents Page
>>
>> Thanks!
>>
>> Dave
>>
>>
>> On Aug 16, 2007, at 9:13 AM, Guido Neitzer wrote:
>>
>>> I have a "dynamicBindings" NSMutableDictionary on my component
>>> superclass,
>>
>>
>
This archive was generated by hypermail 2.0.0 : Thu Aug 16 2007 - 11:56:59 EDT