2010-06-26 52 views
0

好吧,我是Obj-C和Cocoa的新手,但我確信我的綁定在這裏是正確的。我一直在搜索,搜索堆棧溢出,並一次又一次地檢查了我的值。NSTableView和NSMutableArray之間的可可綁定拒絕更新

所以,這裏是我的綁定:

他們連接到這個類:

@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.description]; 
      //NSLog(@"%@", node.description); 
    } 
    [self setMangaList:newArray]; 
    [[self chapterListDownloadIndicator] stopAnimation:self]; 
} 

正如你所看到的,我也嘗試了mutableArrayValueForKey方法,取得了什麼。我知道一個事實mangaList正在獲得物品。

我一直在這個工作了一段時間,並可能犯了一個愚蠢的錯誤。

在此先感謝。

回答

0

事實證明,問題是該窗口沒有設置爲我的窗口控制器/委託文件所有者的類標識。當我設置這個窗口時,窗戶起死回生。

這個問題也阻止了我的NSProgressIndicator的工作。

3

看起來你正在改變陣列控制器背後的mangaList。每當您對mangaList進行更改時,一旦完成更改,您應該先撥打[self willChangeValueForKey:@"mangaList"];,然後撥打[self didChangeValueForKey:@"mangaList"];。這會讓陣列控制器知道它需要查看更改的內容。