Button with IBAction causes “Could not connect action, target class NSNibExternalObjectPlaceholder does not respond to -action” error

一个人想着一个人 提交于 2019-12-12 02:37:06

问题


I have a Storyboard scene which contains an NSTableView with an NSTableViewRow subclass. In this table view row, I have a button which I have wired up to an action in the view controller on the scene.

When the table loads, I am seeing this cryptic error from Xcode and the action never fires when I click the button:

Could not connect action, target class NSNibExternalObjectPlaceholder does not respond to -playVideo:

It looks like the file's owner never gets wired up.

Since these NSTableRowViews get instantiated programmatically, I checked to see if the owner is getting set, and indeed it is:

- (NSView *) tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
...
CombinedHistoryEntryTableCellView *cellView = [tableView makeViewWithIdentifier:@"deviceEvent" owner:self];
...
return cellView;
}

回答1:


I believe I am experiencing a bug (and I will file a radar later) but I was able to work around the issue by wiring the button up to an action on the CombinedHistoryEntryTableCellView class in IB. Since the code needed to run the action was in the view controller I gave the cell view object a reference to the controller so that it could call it.

Still don't know why that was an issue, though, but if someone else experiences this that is a suitable workaround.



来源:https://stackoverflow.com/questions/34646105/button-with-ibaction-causes-could-not-connect-action-target-class-nsnibexterna

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!