Building a dynamic class factory ( +load init order)
Building a dynamic class factory ( +load init order)
- Subject: Building a dynamic class factory ( +load init order)
- From: Thomas Engelmeier <email@hidden>
- Date: Fri, 28 Dec 2007 20:54:31 +0100
Hi,
I have some old code from the Tiger aera that fails on Leopard.
Basically some classes call
+ (void) load
{
NSDictionary *aDictionary = [aDictionary dictionaryWithObjectsAndKeys:
[self class], @"class",
@"plugin name", @"name",
nil]];
[TELibraryFactory registerClass:aDictionary];
}
with a implementation like
+ (void) registerClass:(NSDictionary *) aClass
{
if( !sRegisteredClasses )
sRegisteredClasses = [[NSMutableArray alloc] init];
[sRegisteredClasses addObject:aClass];
}
Seems I relied too much that the Foundation classes are already loaded
and initialized when +load is called - now the dictionary creation
already crashes.
Is there any better way to prevent I have to add
[[TELibraryFactory register:[TESubclass1 description]];
[[TELibraryFactory register:[TESubclass2 description]];
// ...
[[TELibraryFactory register:[TESubclassN description]];
manually in a separate file and keep that in sync each time a new
class is added?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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