我的阵列崩溃了

发布于 2024-10-09 11:04:25 字数 328 浏览 0 评论 0原文

我有一个问题。 我有一个名为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千里故人稀 2024-10-16 11:04:25

您必须确保放入数组中的所有内容都是对象。使用 NSString、NSNumber 和/或 NSValue。

You must make sure that everything you're putting into the array is an object. Use NSString, NSNumber and/or NSValue.

凶凌 2024-10-16 11:04:25

看起来 isOn 返回一个布尔值(根据命名约定判断)。布尔值不能放入 NSArray 中。

您需要使用 numberWithBool: 将其包装在 NSNumber 中。

It looks like isOn returns a boolean (judging by naming convention). Booleans cannot be put into an NSArray.

You'll need to wrap it in an NSNumber using numberWithBool:.

余生共白头 2024-10-16 11:04:25

请那些觉得难以理解的人阅读以下文献:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文