我的阵列崩溃了
我有一个问题。 我有一个名为 toolsViewValues 的数组,当我保存时,我得到一个 “EXC_BAD_ACCESS”,仅此而已... :-(
然而,数组内的对象不是零。
NSArray *toolsViewValues = [[NSArray alloc] initWithObjects:
preferedLanguage,
needsSwitch.isOn,
vocSlider.value,
exprSlider.value,
gramSlider.value,
nil];
知道吗?
非常感谢。
迈克
I have a problem.
I have an array which is called toolsViewValues and when I'm saving, I get an
"EXC_BAD_ACCESS" and that's all... :-(
Yet, the objects inside the array are not nil.
NSArray *toolsViewValues = [[NSArray alloc] initWithObjects:
preferedLanguage,
needsSwitch.isOn,
vocSlider.value,
exprSlider.value,
gramSlider.value,
nil];
Any idea ?
Thanks a lot.
Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须确保放入数组中的所有内容都是对象。使用 NSString、NSNumber 和/或 NSValue。
You must make sure that everything you're putting into the array is an object. Use NSString, NSNumber and/or NSValue.
看起来
isOn
返回一个布尔值(根据命名约定判断)。布尔值不能放入NSArray
中。您需要使用
numberWithBool:
将其包装在NSNumber
中。It looks like
isOn
returns a boolean (judging by naming convention). Booleans cannot be put into anNSArray
.You'll need to wrap it in an
NSNumber
usingnumberWithBool:
.请那些觉得难以理解的人阅读以下文献:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html
我希望这会有所帮助。
再次感谢。
In invite those who find it hard to understand to read the following litterature :
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html
I hope that will help.
Thanks again.