Home  >  Q&A  >  body text

ios - C数组不能作为oc属性吗?

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

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

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

怪我咯怪我咯2720 days ago683

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:09:57

    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];
    }

    reply
    0
  • Cancelreply