• 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
NSArrayController and Class objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArrayController and Class objects


  • Subject: NSArrayController and Class objects
  • From: Rob Keniger <email@hidden>
  • Date: Mon, 20 Aug 2007 18:25:15 +1000

Hi,

I am writing a document-based app that uses templates. To allow the user to choose a template, I am displaying a sheet when a new, untitled document is opened. This sheet displays a list of templates to choose from, in a manner very similar to how it's done in Apple's iWork apps.

I am currently implementing the templates as plugins (loadable bundles) which all contain a single subclass of NSObject that conforms to a special protocol, eg:

@interface MyTemplateObject : NSObject <MyTemplateProtocol>
{}
+(NSString*) name;
+(NSString*) description;
@end

In the nib for the sheet that allows the user to select a template, I have an NSArrayController with its content array bound to an NSArray which contains all the Class objects for the template plugins that are loaded. So, in Interface Builder I have the Mode of the NSArrayController set to "Class" and for the class name I have:

Class <MyTemplateProtocol>

I then bind some text fields to the name and description keys of the array controller's selection.

This seems to work, however I am concerned that the NSArrayController might not expect to find objects of type Class in the NSArray as normally you would have object instances, not object classes, in the array. I suspect that this may cause some unexpected issues (it does log an unusual message when used with GC ).

Am I worrying about nothing? Is there a better way to do this?

--
Rob Keniger

_______________________________________________

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


  • Prev by Date: Re: textStorage readFromURL does not like blanks
  • Next by Date: Core Data didTurnIntoFault:
  • Previous by thread: Re: Displaying line numbers at the left of a subclass of NSTextView
  • Next by thread: Core Data didTurnIntoFault:
  • Index(es):
    • Date
    • Thread