Re: observing dealloc
Re: observing dealloc
- Subject: Re: observing dealloc
- From: James Bucanek <email@hidden>
- Date: Tue, 29 May 2007 07:59:38 -0700
Ken Tozier <mailto:email@hidden> wrote (Tuesday, May
29, 2007 10:22 PM -0400):
The main reason is that with a generalized mechanism, there's no
possibility for static variable name collisions. Many different
classes could all have a "gFoo" global without having to dream up a
different name for each class.
Use static variables.
You could have fifty classes that all implement ...
static id sFoo; // really stupid name
...
@implementation AnyClass
+ (void)initialize
{
// if (sFoo==nil) -- pointless test; initialize only
runs once
sFoot = [[NSObject alloc] init];
}
+ (id)foo
{
return (sFoo);
}
... and you would have no conflicts or confusion. The symbol
name 'sFoo' is local to the scope of module and couldn't
possibly conflict with any similarly named static in another module.
On the other hand, what you're proposed solution would simply
replace global name collisions (which could be caught at link
time) with key value collisions (which wouldn't be caught until
run-time, if ever).
Personally, I think you're over engineering this problem.
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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