How to add string objects to NSMutableArray

前端 未结 6 1157
难免孤独
难免孤独 2021-01-01 10:06

I have an NSMutableArray named randomSelection:

NSMutableArray *randomSelection;

I am then trying to add strings to this array if certain c

6条回答
  •  说谎
    说谎 (楼主)
    2021-01-01 11:07

    Swift :

    var randomSelection: [AnyObject] = [AnyObject]()
    randomSelection.append("string1")
    let test: String = randomSelection[0] as! String
    print(test)
    

    OR

    let array : NSMutableArray = []
    array.addObject("test String")
    print(array)
    

提交回复
热议问题