【发布时间】:2014-04-19 05:12:55
【问题描述】:
好的,这快把我逼疯了,我有一个我一直在开发的 Xcode OSX 应用程序。我最近做了一些更改,并且在编译时开始出现以下错误:
iModerate Desktop[72478:303] *** Illegal NSTableView data source (<NSView: 0x102535290>).
Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:
我无法锻炼这是从哪里来的,我已经在我的 appDelegate 中实现了这两种方法:
- (NSView *)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
// The return value is typed as (id) because it will return a string in most cases.
id returnValue=nil;
// The column identifier string is the easiest way to identify a table column.
NSString *columnIdentifer = [tableColumn identifier];
// Get the name at the specified row in namesArray
NSString *theName = [[self.twitterClientsController arrangedObjects] objectAtIndex:row];
// Compare each column identifier and set the return value to
// the Person field value appropriate for the column.
if ([columnIdentifer isEqualToString:@"name"]) {
returnValue = theName;
}
return returnValue;
}
还有这个
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return[[self.twitterClientsController arrangedObjects] count];
}
并且应用代理设置为 NSTableViewDelegate
现在更奇怪/令人沮丧的是,我在 xib 中没有 NSTableView,但我已将它们全部删除。我已经在 BBedit 中打开了 XIB 并搜索了 NSTableView 并且 100% 没有!
所以,请帮忙!如果我能弄清楚 NSView: 0x102535290 是什么,我可能会找到它。
非常感谢您帮助挽救我的理智!
加雷斯
【问题讨论】:
-
尝试
NSLog(@"%p@,self);在您的委托类中某处打印其地址,并将其与错误中报告的委托地址进行比较。他们应该匹配。只是看看代理是否设置正确。 -
这仍然是一个问题吗?确保您没有任何其他导致此问题的 xibs
-
老实说,我真的无法解决这个问题,所以我只是通过 git 恢复了我的更改并重新进行了更改,这很好。非常非常奇怪。
标签: objective-c xcode macos nstableview