我有三个NSInteger类型的变量,问题是你如何将NSInteger放入数组或数据集中?
- (void)someNumber {
NSInteger one = 1;
NSInteger two = 2;
NSInteger three = 3;
// how do you put the NSInteger in an array or data set?
}
答案 0 :(得分:1)
只需制作NSArray
个人吗?
NSArray *all = @[@(one), @(two), @(three)];
使用NSNumber
运算符将它们装入@
个对象。
答案 1 :(得分:0)
您必须将NSInteger
作为NSNumber
存储在NSArray
中,如下所示
- (void)someNumber {
NSInteger one = 1;
NSInteger two = 2;
NSInteger three = 3;
// how do you put the NSInteger in an array or data set?
NSArray *numberGroup = [NSArray arrayWithObjects:[NSNumber numberwithInteger:one],[NSNumber numberwithInteger: two],[NSNumber numberwithInteger: three]];
}