Re: NSArrayController using an external NSArray?
Re: NSArrayController using an external NSArray?
- Subject: Re: NSArrayController using an external NSArray?
- From: Todd Heberlein <email@hidden>
- Date: Thu, 19 Apr 2007 20:51:14 -0700
On Apr 19, 2007, at 8:02 PM, Todd Heberlein wrote:
On Apr 19, 2007, at 5:25 PM, Ron Aldrich wrote:
[[self mutableArrayValueForKey: @"myArray"] addObject: anObject];
Unfortunately, this did not work either. ... I must still be doing
something wrong.
Yep, I made two mistakes. First, I overrode mutableArrayValueForKey
for testing purposes, and once I removed this it almost started
working. My NSMutableArray and the NSTableView were both updated
correctly, but the program would eventually crash.
I then added the following methods to my model (note: my
NSMutableArray is called "processes"):
- (unsigned int)countOfProcesses;
- (id)objectInProcessesAtIndex:(unsigned int)index;
- (void)insertObject:(id)anObject inProcessesAtIndex:(unsigned int)
index;
- (void)removeObjectFromProcessesAtIndex:(unsigned int)index
- (void)replaceObjectInProcessesAtIndex:(unsigned int)index
withObject:(id)anObject;
and gave them the very simple implementations shown below. As of
now... everything seems to be working, and I can make my model
unaware of the NSArrayController again. Yay!
Thanks!
Todd
- (unsigned int)countOfProcesses
{
return [processes count];
}
- (id)objectInProcessesAtIndex:(unsigned int)index
{
return [processes objectAtIndex:index];
}
- (void)insertObject:(id)anObject inProcessesAtIndex:(unsigned int)index
{
[processes insertObject:anObject atIndex:index];
}
- (void)removeObjectFromProcessesAtIndex:(unsigned int)index
{
[processes removeObjectAtIndex:index];
}
- (void)replaceObjectInProcessesAtIndex:(unsigned int)index
withObject:(id)anObject
{
[processes replaceObjectAtIndex:index withObject:anObject];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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