简体   繁体   English

数组中的NSNumber

[英]NSNumber from array

I have an array, and I am trying to get an integer in my array into a int or NSInteger. 我有一个数组,并且试图将数组中的整数转换为int或NSInteger。 It uses NSDictionaries. 它使用NSDictionaries。 The following code does not work: 以下代码不起作用:

int color = [[records objectAtIndex:0] valueForKey: @"color"];

Note that I am using a Core Data Fetch that saves into an array called "records". 请注意,我使用的是Core Data Fetch,该数据保存到名为“ records”的数组中。

Thanks 谢谢

尝试这个:

int color = [[[records objectAtIndex:0] valueForKey: @"color"] intValue];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM