ADDOBJECT AS NSMUTABLEARRAY IN SWIFT

Kamlakar Singh

Total Post:194

Points:1396
Posted by  Kamlakar Singh
iPhone  Ios 
 8298  View(s)
Ratings:
Rate this:
I want to addObject of NSMutableArray into NSMutableArray so how can I achieve this in swift. and also retrieve it so please help me because right now I'm learning swift.

Indirectly say that I want 2D array means NSMutableArray of NSMutableArray.

//The below 2 lines iterative!
var dict:NSMutableDictionary? = NSMutableDictionary();
 linePointsArray!.addObject(dict!);

// and below 2 line is execute after complete the above iteration
 arrLine!.addObject(linePointsArray!);
 linePointArray!.removeAllObject();

//after that the above whole process is done iterative.
  1. Pawan Shukla

    Post:38

    Points:274
    Re: AddObject as NSMutableArray in swift

    If I am not wrong you want to add an object of NSMutableArray in another NSMutableArray you can do it by following code

    var myArray : NSMutableArray = ["Hello"]
    var arrayOfArray : NSMutableArray = [myArray]

    // Insert more arrays with insertObject or addObject

    arrayOfArray.insertObject(myArray, atIndex: 0)
    arrayOfArray.addObject(myArray)

    //Retrive
    var newArray:NSMutableArray = arrayOfArray[0] as NSMutableArray
    println("\(newArray)")

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!