ios - C数组不能作为oc属性吗?
怪我咯
怪我咯 2017-04-17 16:07:57
0
1
752

想要用oc编写一个栈模型,必然要用到数组,用NSMutableArray似乎有些笨重,但是又不能将C数组塞到oc对象的属性中,例如下面这样:

@property int[];
@property int[100];

难道只能用NSMutableArray,今天写了一下,光是NSNumber的装箱脱箱代码就写了一大坨,太不优雅了,哼

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
Ty80

No, property cannot have array or function types. The original design concept is to better manage the life cycle of object types. If you want to use property to define arrays or functions, you can do it through pointers (if it is a basic data type pointer) assign attribute).
Or you can also write like this

@interface subClass : superClass{
    @public
    int array[10];
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template