NSDictionary objectForKey iPhone模拟器和iPhone设备
我有这个函数 return [remoteObject objectForKey:key];
,它应该返回我字典中的一个对象。
当我启动 Iphone 模拟器时,一切都很好并且它返回正确的对象。 但是当我在我的设备上启动同一个应用程序时,我的应用程序崩溃了,并且显示 SIGABRT 和
2011-12-05 10:25:17.601 iPhoneXMPP[242:1a1f] -[CALayer objectForKey:]: 无法识别的选择器发送到实例 0x4f3d40 2011-12-05 10:25:17.602 iPhoneXMPP[242:1a1f] * 由于未捕获而终止应用程序 异常'NSInvalidArgumentException',原因:'-[CALayer objectForKey:]: 无法识别的选择器发送到实例 0x4f3d40'
我的密钥是一个 Id (17),它也在我的字典中。
你们有人知道为什么这种情况只发生在我的设备上吗?
I have this function return [remoteObject objectForKey:key];
which should return an object that is in my dictionary.
When I am starting the Iphone simulator everything is fine and it returns the right object.
But when I am starting the same application an my device my application crashes and it says SIGABRT
and
2011-12-05 10:25:17.601 iPhoneXMPP[242:1a1f] -[CALayer objectForKey:]:
unrecognized selector sent to instance 0x4f3d40 2011-12-05
10:25:17.602 iPhoneXMPP[242:1a1f] * Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[CALayer
objectForKey:]: unrecognized selector sent to instance 0x4f3d40'
My key is an Id (17) and it is also in my dictionary.
Does anybody of you knows why this happens only on my device?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着您的
remoteObject
对象正在某处被释放。通常,自动释放在设备上发生得更快,因为它的内存比模拟器少,这就是为什么在模拟器上,当您尝试调用它的方法时,您的对象仍然存在。确保在创建对象时调用retain
,并在使用完对象后调用release
。It means that your
remoteObject
object is being deallocated somewhere. Usually autoreleases happen faster on the device because it has less memory than the simulator that's why on the simulator your object is still there when you are trying to call it's method. Make sure you callretain
on your object when you created it andrelease
when you are done with it.