IOS: fill a NSMutableArray with some NSMutableArray
In my project I must fill an NSMutableArray with some NSMutable array, my code is:
This is a method
-(void) fill {
[smal开发者_StackOverflow中文版lArray removeAllObjects]; //when I call this method I delete every object inside smallArray
for {
//in this for I fill with some object a NSMutableArray that I called "smallArray"
[smallArray addObject:object];
}
//outside this for I have my NSMutable bigArray that I must fill with smallArray
[bigArray = ?????];
How can I fill this bigArray?
Unlesss I'm missing something, simply use the addObject:
method (as you're already doing for the small array), supplying the smallArray to add.
i.e.: [bigArray addObject:smallArray];
If however you just want to add the objects from smallArray into the bigArray, then you could use the addObjectsFromArray:
method...
[bigArray addObjectsFromArray:smallArray];
...which will append the objects after any existing ones within bigArray. For more information, check out the relevant section of the NSMutableArray Class Reference documentation.
If i understang correctly you must have an array that contains other arrays?
[bigArray addObject:smallArray];
Then you can access the array like this
NSMutableArray * arrayfromArray =[bigArray objectAtIndex: someIndex];
精彩评论