Cocoa bindings between NSTableView and NSMutableArray refuse to update
Ok, I'm very new to Obj-C and Cocoa, but I'm sure my bindings here are correct. I've been googling, searching stack overflow and have checked my values again and again.
So, here are my bindings:
They connect to this class:
@interface TMMaddMangaWindowDelegate : NSWindowController {
...
}
...
@property (copy) NSMutableArray* mangaList;
...
@end
@implementation TMMaddMangaWindowDelegate
...
@synthesize mangaList;
// - (NSMutableArray*) mangaList {
// NSLog(@"mangaList was called!");
// return mangaList;
//}
//- (void) setMangaList:(NSMutableArray *) input{
// NSLog(@"setMangaList was called!");
// [mangaList autorelease];
// mangaList = [input retain];
//}
...
-(void) populateList:(NSArray*)list{
NSMutableArray* newArray = [[NSMutableArray alloc] initWithArray:list];
NSLog(@"Populating List.");
for(NSXMLNode* node in list){
[newArray addObject:node.description];
//[[self mutableArrayValueForKey:@"mangaList"] addObject:node.descript开发者_Go百科ion];
//NSLog(@"%@", node.description);
}
[self setMangaList:newArray];
[[self chapterListDownloadIndicator] stopAnimation:self];
}
As you can see, I also tried the mutableArrayValueForKey
approach, which yielded nothing. I know for a fact mangaList is gaining items.
I've been working on this for a while, and probably made a stupid mistake.
Thanks in advance.
It looks like you are changing mangaList
behind the array controller's back. Whenever you are making a change to mangaList
you should first call [self willChangeValueForKey:@"mangaList"];
and then [self didChangeValueForKey:@"mangaList"];
once you are done with the change. this will let the array controller know it needs to take a look at what changed.
It turns out that the problem was that the window did not have the class identity of Files Owner set to my window controller/delegate. The moment I set this the window sprang to life.
That problem was also preventing my NSProgressIndicator from working.
精彩评论