Re: Accessor methods and (auto)release <Memory trail>
Re: Accessor methods and (auto)release <Memory trail>
- Subject: Re: Accessor methods and (auto)release <Memory trail>
- From: Ali Ozer <email@hidden>
- Date: Fri, 2 Aug 2002 09:10:01 -0700
So, is the above pattern (getter which retains and autoreleases) used
in Cocoa at all? Or, is it just a theoretically correct, but
practically for diverse reasons never (or extremely rarely) used one?
Good question... You're right that not many classes that can use this
technique do right now.
As mentioned before, a few low-level classes (such as the collections,
attributed string, etc) don't and won't use this technique because they
are collections and don't want to fiddle with the lifetime of your
objects.
Many other classes use other techniques, mostly due to the fact their
set/get methods were written many years ago when we were still
enumerating the techniques, still looking at the performance
characteristics, and not as much aware of thread safety issues. We
have actually fixed some cases in Jaguar to use this exact technique,
and will probably continue to do so as long as we don't introduce any
serious binary incompatibilities (which is unfortunately a serious
threat)...
But, I believe that especially for people just approaching Cocoa and
for anyone writing new classes, this get/set pattern is the most
appropriate unless there are significant performance concerns like
"getter will be called a lot".
Ali
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.