• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Building a dynamic class factory ( +load init order)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Building a dynamic class factory ( +load init order)
      • From: "Ken Ferry" <email@hidden>
    • Re: Building a dynamic class factory ( +load init order)
      • From: "Jonathan del Strother" <email@hidden>
  • Prev by Date: Re: Scripting Bridge && filteredArrayUsingPredicate
  • Next by Date: QTTrack is awfully limiting
  • Previous by thread: NSTextView Linked Text Font Attributes Issues
  • Next by thread: Re: Building a dynamic class factory ( +load init order)
  • Index(es):
    • Date
    • Thread