Re: KVO and accessors - are they needed
Re: KVO and accessors - are they needed
- Subject: Re: KVO and accessors - are they needed
- From: "John C. Randolph" <email@hidden>
- Date: Tue, 19 Oct 2004 19:36:09 -0700
On Oct 19, 2004, at 7:23 PM, Bruce Truax wrote:
I have been religiously creating and using set and get accessors for
all
variables for which I use KVO. This is recommended by the
documentation but
the documentation also states that if the accessors are not present the
variable will still be accessed using default set and get methods. I
have a
couple of classes with a large number of variables for which I use KVO
and
binding. These classes have a lot of methods, 90% of which are set
and get
methods for floats, ints, NSStrings, BOOL's etc. The classes would be
much
smaller and easier to read without all of these methods. What do the
experts recommend?
Well, YMMV of course, but Keep in mind that when KVC has to go looking
for your ivars, it has to do a bunch of wading through the Obj-C
runtime that isn't necessary if you provide accessor methods.
Personally, I recommend generating the accessors with an app like
accessorizer. If they're cluttering up your code, use a category
(like, say: MyClass (accessors) ) and stick them in separate .m files.
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden