2013-02-08 40 views
1

我有一個NSMutableArray填充NSMutableDictionaries。所有這些數據都顯示在NSTableView中。無法編輯NSTableView中的表格

問題是當我嘗試編輯單元格時。我的tableview綁定到我的類與數據源綁定。並編輯單元格的值我用這個代碼:

-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ 

NSMutableDictionary *i = [list objectAtIndex:row]; 
NSString *identifier = [tableColumn identifier]; 
[i setValue:object forKey:identifier]; 

} 

但其異常觸發的錯誤:

2013-02-11 20:50:35.960 prog[424:303] Exception detected while handling key input. 
2013-02-11 20:50:35.960 prog[424:303] [<__NSDictionaryI 0x105986580>  setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key filename. 
2013-02-11 20:50:35.964 prog[424:303] (

我不知道爲什麼我收到此錯誤NSDictionaryI。即使我將字典添加到數組中,我仍在使用NSMutableDictionary。任何幫助讚賞。

回答

0

我發現問題了!

當我添加元素到我的數組我使用COPY。刪除它使其工作!

[myNSMutableArray addObject: myNSMutableDictionary];

我使用

[myNSMutableArray addObject:copy myNSMutableDictionary];

0

我覺得

setValue:forUndefinedKey 

手段,你有你的TableColumn的標識符的問題。檢查Interface Builder中的設置標識符和/或設置一個斷點(或者只是做一個NSLog(@「%@」,tableColumn.identifier);)

+0

感謝之前,卻發現問題了!無論如何謝謝你的嘗試! – sharkyenergy 2013-02-12 07:02:26