NSUserDefaults 给出错误
我在我的应用程序中使用 NSUserDefaults 。它工作正常,直到我有 ios 4.3 和 xcode 4.0。但现在我已经更新到 ios 5 和 xcode 4.2...
它给出了错误!
NSString *storedLanguage = [[NSUserDefaults standardUserDefaults] objectForKey:@"language"];
*** -[NSUserDefaults objectForKey:]: message sent to deallocated instance 0x26e800
我不知道如何解决它..我已经尽力了!
任何帮助将不胜感激!
谢谢
I am using NSUserDefaults in my application. It was working fine until i was having ios 4.3 and xcode 4.0. But now i have updated to ios 5 and xcode 4.2...
It's giving error!
NSString *storedLanguage = [[NSUserDefaults standardUserDefaults] objectForKey:@"language"];
*** -[NSUserDefaults objectForKey:]: message sent to deallocated instance 0x26e800
I don't know how to resolve it..i have tried all my effort!
Any help will be appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从你的问题来看,它看起来像是某个对象的早期发布。
说不出问题出在哪里。
但尝试一下这个
================================= 或 =========== =====================
这个
他们可能会帮助你......
干杯
Well from your question its looking like early release of some object.
Cant say where is the problem.
But give a try to this one
=============================== OR ================================
This one
They might help you...
Cheers
请执行 Naved 所说的相同操作,但稍加修改。
Please do the same thing said by Naved but with little modification.
对您的设置使用不与保留(现有但不可访问)设置名称冲突的不同键。 (例如“MyUsersLanguageSettingsKey”)
Use a different key for your settings that doesn't collide with reserved (existing but inaccessible) setting names. (e.g. "MyUsersLanguageSettingsKey")
现在工作正常了..实际上ios5中有一个东西。如果您在一个类中释放 nsdefaults,则无法在应用程序中的任何位置使用。
我在 appdelegate 文件中释放了 NSDefaults。所以它在其他类中不起作用..但它在ios4中工作..我不知道为什么它在这里工作?
感谢大家抽出时间!!
It's working fine now.. Actually there is one thing in ios5. If you release your nsdefaults in one class, you can't use anywhere in the application..
I was releasing the NSDefaults in my appdelegate file. so it was not working in other classes..But it was working in ios4.. I don't know why it was working here?
Thanks to all for giving time!!