Obj-C中此数组的同义词是什么

时间:2010-11-09 20:13:33

标签: objective-c arrays

Obj-C中此数组的同义词是什么?

int month[12] = {31,0,31,30,31,30,31,31,30,31,30,31};

由于

2 个答案:

答案 0 :(得分:2)

Objective-C是C的超集,因此您建议的数组可以用于Objective-C代码。

如果您对使用Objective-C数据结构感兴趣,我会从NSArrayNSNumber个实例开始,然后从那里开始工作。

答案 1 :(得分:2)

您可以在objective-c代码中自由使用c数组。但是如果你真的需要使用objective-c类型的数组,你将拥有以下内容(请注意,objective-c容器只能包含objective-c类型的对象):

NSArray *month = [NSArray arrayWithObjects:[NSNumber numberWithInt:31],
                                           [NSNumber numberWithInt:0],
                                           ...
                                           [NSNumber numberWithInt:31], nil];
相关问题