Binding : NSArrayController does not reflect changes to NSMutableArray
Binding : NSArrayController does not reflect changes to NSMutableArray
- Subject: Binding : NSArrayController does not reflect changes to NSMutableArray
- From: "Mike Chambers" <email@hidden>
- Date: Thu, 27 Nov 2008 00:12:57 -0800
First, I am new to Cocoa, so I apologize if this question is super simple.
I am currently reading through "Cocoa Programming for Max OS X", and
am trying to create a simple example of a NSTableView that is bound to
an NSArrayController which is bound to an NSMutableArray in my
application controller class.
However, when I change (i.e. add) data in the NSMutableArray the
changes are not reflected in the NSArrayController. If I modify the
NSArrayController directly, I can see the changes in the NSTableView
After a lot of searching, I found this post:
http://chanson.livejournal.com/85659.html
which basically says changes to NSMutableArray will not automatically
be picked up by the NSArrayController. However, even If I implement
the solutions in that post, it is still not working for me.
For example:
-----
-(id)init
{
if(![super init])
{
return nil;
}
broadcasts = [[NSMutableArray alloc] init];
return self;
}
-(void)awakeFromNib
{
NSLog(@"hello");
Broadcast *b = [[Broadcast init] alloc];
b.startTime = @"1000";
//[broadcasts addObject:b];
[self insertObject:b intoBroadcastsAtIndex:[self countOfBroadcasts]];
}
-(void)insertObject:(Broadcast *)b intoBroadcastsAtIndex:(int)index
{
[broadcasts insertObject:b atIndex:index];
}
-(int)countOfBroadcasts
{
return [broadcasts count];
}
---
So, I have two questions:
1. Should I just manipulate NSArrayController directly? (I am
populating data from a tab delimited file).
2. Does anyone have an example of how to get the NSArrayController to
notice the changes to the NSMutableArray that it is bound to?
3. Should I just skip all of the data binding, and glue up everything myself?
Thanks for any help and input...
mike
_______________________________________________
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