Re: Initialization order
Re: Initialization order
- Subject: Re: Initialization order
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 9 May 2003 12:47:39 -0700
On Friday, May 9, 2003, at 01:17 PM, Mark Levin wrote:
Is there any way to control or determine the order in which
+initialize is called for classes?
No.
I would like to create an object containing a list of a subset of my
classes, and initialize seems like a natural place to do it. But this
means I have to find a way to lay the foundation for the
object/structure managing the registry before init is called for any
of the classes I am interested in. Anyone have suggestions for this?
Make sure that the act of attempting to insert a class in this registry
creates the registry if it doesn't already exist.
e.g:
static NSMutableArray *someListOfClasses;
@interface NSObject (myRegistry)
+ listOfClassesICareAbout
{
if (!someListOfClassses)
someListOfClasses = [[NSMutableArray alloc] initWithCapacity:10];
return someListOfClasses;
}
@end
and whenever you need to register some class, just call
[[[self class] listOfClassesICareAbout] addObject:[self class]];
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.