Re: Need help wrapping my head around bindings
Re: Need help wrapping my head around bindings
- Subject: Re: Need help wrapping my head around bindings
- From: mmalc crawford <email@hidden>
- Date: Mon, 10 Dec 2007 20:59:24 -0800
On Dec 10, 2007, at 6:21 PM, Cem Karan wrote:
1) When I create a class instance, it has instance variables. The
Objective-C 2.0 method for accessing these is via the @property
directive. Does using @property automatically make an instance KVO
compliant
No. Just as with KVC (<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_5.html
>), KVO and properties are orthogonal technologies.
Using @property per se does not "automatically make an instance KVO
compliant": typically it will be KVO-compliant by default, but your
class may suppress automatic key-value observing and you could specify
non-KVO-compliant accessors for the property.
That is, would the following declaration (the the corresponding
@synthesize) make 'contents' something I can bind to?
@interface CFKcontroller : NSObject {
NSMutableArray *contents;
}
@property(retain) NSMutableArray *contents;
@end
Given this specification, yes you could bind to 'contents'.
But to preserve encapsulation you should almost certainly copy rather
than retain the array, and you should implement your own set accessor
to create a mutable copy. For efficiency, you should also implement
the indexed accessors as shown in <http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB
>.
2) Assuming that #1 is correct, how do I bind to it using an array
controller?
Just as you would any other array.
I have tried to a) using an array controller bound to CFKcontroller
for its content, with 'contents' as its key,
What actual binding did you set -- 'contentArray'?
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden