在 Instruments 中运行的 iPhone 应用程序因无法识别的选择器而失败
我有一个应用程序,在正常使用中似乎运行没有问题。 Clang Static Analyzer 也没有报告任何问题。 当我尝试在 Instruments 中运行它时,它失败并出现无法识别的选择器异常。
有问题的行是一个简单的属性设置器,其形式为:
self.bar = baz;
为了弄清楚发生了什么,我在其上方添加了一个 NSLog() 调用:
NSLog(@"class = %@ responds = %d", [self class], [self respondsToSelector:@selector(setBar:)]);
self.bar = baz;
在模拟器(没有仪器)和设备上,这准确地显示了我所期望的内容:
class = Foo responds = 1
在 Instruments 下运行时,我得到:
class = Foo responds = 0
我很困惑什么会导致这种情况。 当仪器环境中时,是否可能会占用不同的内存位置? 谁能建议我如何调试这个?
I have an app that appears to run without problems in normal use. The Clang Static Analyzer reports no problems either. When I try to run it in Instruments, it fails with an unrecognized selector exception.
The offending line is a simple property setter of the form:
self.bar = baz;
To figure out what's going on, I added an NSLog() call immediately above it:
NSLog(@"class = %@ responds = %d", [self class], [self respondsToSelector:@selector(setBar:)]);
self.bar = baz;
On the emulator (without Instruments) and on a device, this shows exactly what I'd expect:
class = Foo responds = 1
When running under Instruments, I get:
class = Foo responds = 0
I'm stumped as to what could cause this. Perhaps a different memory location is getting tromped on when it's in the Instruments environment? Can anyone suggest how I might debug this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果 bar 属于 self,你不能这样做
bar=baz;
吗?If bar belongs to self, can't you do
bar=baz;
?检查你的财产。
也许你需要巴兹的演员阵容?
Check your properties.
Perhaps to you need a cast on baz?
这里没有足够的信息来了解发生了什么,但是,如果您知道要提供哪些信息,您可能已经修复了它。 所以。 有几件事需要检查:
setBar:
方法,您还会收到错误吗?There's not enough information here to know what's going on, but then, if you knew what information to provide you'd probably have already fixed it. So. A few things to check:
self
at various points just for sanity's sakesetBar:
method, do you still get the error?