• 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 Howto use in simple non-document application?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArrayController Howto use in simple non-document application?


  • Subject: NSArrayController Howto use in simple non-document application?
  • From: Tod Cunningham <email@hidden>
  • Date: Mon, 15 Mar 2004 03:11:51 -0500

I am trying to use the "new" spiffy NSArrayController model in a non-document based Cocoa application. I created an instance of my model in IB and it exposes through key-value coding a single array (groupList):

- (unsigned int)countOfGroupList;
- (id)objectInGroupListAtIndex:(unsigned int)index;
- (void)insertObject:(id)anObject inGroupListAtIndex:(unsigned int)index;
- (void)removeObjectFromGroupListAtIndex:(unsigned int)index;
- (void)replaceObjectInGroupListAtIndex:(unsigned int)index withObject:(id)anObject;

- (NSMutableArray *)groupList;
- (void)setGroupList:(NSMutableArray *)newGroupList;

Do I really need all those, or are the first 4 enough? The object returned (id) is a simple custom object that also uses key-value coding to expose two properties:

- (NSString *)address;
- (void)setAddress:(NSString *)address;

- (NSString *)name;
- (void)setName:(NSString *)name;

I want to display the name and address in a table in my view. Sounds simple enough. In IB, how do I connect the instance of model to the instance of NSArrayController? I try setting the controller's contentArray binding to point to my model instance, but the only choices are "File's Owner" and "Shared User Defaults". Also, I am not sure if I should set the controllers "Object Class Name" attribute to be the same as the object type I return from objectInGroupListAtIndex. Can someone point me to some good "Non-Document" based examples or offer some words of wisdom? I have tried many combinations and I either end up crashing IB or get "this class is not key value coding-compliant for the key groupList" exceptions when I tried making my model the the "File's Owner".

Thanks,

Tod Cunningham
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSArrayController Howto use in simple non-document application?
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: pdf data to graphic objects
  • Next by Date: lost with help books
  • Previous by thread: Re: Weird UserDefaults problem
  • Next by thread: Re: NSArrayController Howto use in simple non-document application?
  • Index(es):
    • Date
    • Thread