NSArrayController Howto use in simple non-document application?
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.