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
Delivered-to: email@hidden
Delivered-to: email@hidden
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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.