---
title: "AddObject as NSMutableArray in swift"  
description: "AddObject as NSMutableArray in swift"  
author: "Anonymous User"  
published: 2014-10-18  
updated: 2014-10-18  
canonical: https://www.mindstick.com/forum/2416/addobject-as-nsmutablearray-in-swift  
category: "iphone"  
tags: ["iphone", "ios"]  
reading_time: 1 minute  

---

# AddObject as NSMutableArray in swift

I want to addObject of NSMutableArray into NSMutableArray so how can I achieve this in swift. and also [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) it so please help me because [right now](https://answers.mindstick.com/qa/36863/what-would-happen-if-gravity-became-5-percent-stronger-right-now) I'm [learning](https://www.mindstick.com/articles/126221/instructional-design-for-elearning-why-it-is-so-important) swift.\
Indirectly say that I want [2D array](https://www.mindstick.com/forum/1796/how-to-convert-jagged-array-to-2d-array) means NSMutableArray of NSMutableArray.\
//The below 2 lines iterative![var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) dict:NSMutableDictionary? = NSMutableDictionary(); linePointsArray!.addObject(dict!);\
// and below 2 line is [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) after complete the above iteration arrLine!.addObject(linePointsArray!); linePointArray!.removeAllObject();\
//after that the above whole [process](https://yourviews.mindstick.com/story/1525/7-important-factors-that-may-affect-the-learning-process) is done iterative.

## Replies

### Reply by Anonymous User

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 addObjectarrayOfArray.insertObject(myArray, atIndex: 0)arrayOfArray.addObject(myArray)//Retrivevar newArray:NSMutableArray = arrayOfArray[0] as NSMutableArrayprintln("\(newArray)")
```


---

Original Source: https://www.mindstick.com/forum/2416/addobject-as-nsmutablearray-in-swift

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
