FROM : Sherm Pendley
DATE : Wed Nov 24 22:27:13 2004
On Nov 24, 2004, at 2:58 PM, Ricky Sharp wrote:
> Also, for foo, should I really be calling the accessor everywhere
> rather than having a local?
In general, it's a good idea to use accessors any time you need to do
more than a simple assignment.
One example when you have an ivar that's an object type. Generally,
when you assign it a new value, you retain the new value and
(auto)release the old value. Consistently using an accessor in that
case will isolate your memory management into one place, making it less
likely to have retain/release bugs, and easier to debug if it does.
Another example is threading. If you're using mutexes to coordinate
access to an ivar among multiple threads, it's not a bad idea to
isolate all of that mutex-related code into accessor methods.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
DATE : Wed Nov 24 22:27:13 2004
On Nov 24, 2004, at 2:58 PM, Ricky Sharp wrote:
> Also, for foo, should I really be calling the accessor everywhere
> rather than having a local?
In general, it's a good idea to use accessors any time you need to do
more than a simple assignment.
One example when you have an ivar that's an object type. Generally,
when you assign it a new value, you retain the new value and
(auto)release the old value. Consistently using an accessor in that
case will isolate your memory management into one place, making it less
likely to have retain/release bugs, and easier to debug if it does.
Another example is threading. If you're using mutexes to coordinate
access to an ivar among multiple threads, it's not a bad idea to
isolate all of that mutex-related code into accessor methods.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
| Related mails | Author | Date |
|---|---|---|
| Sanoop | Nov 24, 07:17 | |
| Wade Tregaskis | Nov 24, 07:25 | |
| j o a r | Nov 24, 07:32 | |
| Sanoop | Nov 24, 09:37 | |
| Shawn Erickson | Nov 24, 18:03 | |
| Ricky Sharp | Nov 24, 20:58 | |
| Scott Stevenson | Nov 24, 21:32 | |
| Sherm Pendley | Nov 24, 22:27 | |
| Ricky Sharp | Nov 24, 22:41 | |
| M. Uli Kusterer | Nov 25, 21:47 | |
| Andrew Farmer | Nov 26, 23:00 |






Cocoa mail archive

