How to initialize an empty mutable array in Objective C

后端 未结 8 2188
谎友^
谎友^ 2021-02-12 13:02

I have a list of objects (trucks) with various attributes that populate a tableview. When you tap them they go to an individual truck page. There is an add button which will add

相关标签:
8条回答
  • 2021-02-12 13:52

    You can also initialize in this way

    Another way for Objective C apart from the answer of @NSSam

    NSMutableArray *myMutableArray = [@[] mutableCopy];
    

    For Swift

    let myArray = NSMutableArray()
    

    OR

    let myArray = [].mutableCopy() as! NSMutableArray;
    
    0 讨论(0)
  • 2021-02-12 13:56

    I use this way to initialize an empty mutable array in Objective C:

    NSMutableArray * array = [NSMutableArray arrayWithCapacity:0];
    
    0 讨论(0)
提交回复
热议问题