我工作的家庭作业#3 CS193P(Fall 2010),图形计算器。我成功实现了委托来传递表达式和比例,现在正在尝试向委托中添加一个额外的字段,如我的earlier question中所引用的。“无法识别选择”错误时访问委托
以下是错误:
>2011-09-27 20:27:24.076 Graphing Calculator[8892:f803] -[GraphViewController errorForGraphView:]: unrecognized selector sent to instance 0x6c32d10
2011-09-27 20:27:24.077 Graphing Calculator[8892:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GraphViewController errorForGraphView:]: unrecognized selector sent to instance 0x6c32d10'
*** First throw call stack:
(0x13bb062 0x154cd0a 0x13bccfd 0x13bd093 0x13220d9 0x1321cf2 0x8876 0x8d83 0x5ca23 0x1d97c13 0x1daa129 0x1cca15d 0x1da9fce 0x1d97ced 0x1d9e27d 0x1d97d13 0x1da1c58 0x1d27fb5 0x1d29ea2 0x1d2957c 0x138f9de 0x1326680 0x12f2516 0x12f1dd4 0x12f1ceb 0x12a4879 0x12a493e 0x1e38b 0x287f 0x27d5 0x1)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
(gdb)
而这里就是SIGABRT显示了一行:
BOOL error = [self.delegate errorForGraphView:self];
可以在GraphView.m在我Graphing Calculator在GitHub项目中找到。我在iOS 5测试版中使用ARC。
更新
我要补充有在CalculatorBrain类中定义的方法errorForGraphView。我错过了什么(我对代表的理解是前生的),导致每个人都在GraphViewController中查找方法?我应该如何将信息从CalculatorBrain传递给GraphView?
这可能是一个愚蠢的问题......你尝试过实现'errorForGraphView:'方法吗? – darvids0n
是的,你可以在CalculatorBrain.m [链接](https://github.com/mangoldm/Graphing-Calculator/blob/master/Graphing%20Calculator/CalculatorBrain.m) –
但是,这是物体的底部看到它作为委托传递的是一个GraphViewController。奇怪的是,即使GraphViewController采用了GraphViewDelegate协议,它也没有实现该方法。并非GitHub上的所有内容都是无错误的。 –