The solution to both of these problems is non-synchronizing components. When components are not synchronized, they behave more like dynamic elements in that values are not pushed or pulled until they are needed.
To create a non-synchronizing nested component, do the following:
//parent component's .wod file MySubcomponent : NonSyncComponent { stringValue = @"I'm a string!"; }Suppose NonSyncComponent contains a WOString element that it declares in this way:
// NonSyncComponent.wod MyString : WOString { value = someStringValue; }If NonSyncComponent's script file looks like the following, the value that the parent bound to the stringValue attribute is pushed and pulled to WOString's value attribute whenever WOString requests it. Thus, the WOString in this NonSyncComponent displays "I'm a string!"
// NonSyncComponent.wos - synchronizesVariablesWithBindings { return NO; } - someStringValue { return [self valueForBinding:@"stringValue"]; } - setSomeStringValue:aValue { [self setValue:aValue ForBinding:@"stringValue"]; }If NonSyncComponent has no other need for someStringValue than to resolve the value attribute for its WOString, then NonSyncComponent can instead use this shorthand notation in its declarations file:
// Alternate NonSyncComponent.wod MyString : WOString { value = ^stringValue; }The carat (^) syntax means "use the value that my parent bound to my stringValue attribute to resolve value." This syntax is a convenience that saves you from having to always write cover methods for valueForBinding: and setValue:forBinding:. In addition to being more convenient, this syntax is often more efficient because none of your code is invoked to do either the pushing or the pulling.
Table of Contents Next Section