Can you store an Array ( that contains another two subarrays one being a string and another another array) into a single MutableArray object?
Please read the documentation on NSArray. It can contain any number of arbitrary objects.
That said, without knowing more about what you're doing, I'd suggest you look at NSDictionary and its mutable subclass.
Yes, you can store any type of object into one of the NSArray classes. The only difficulty is in conceptually dealing with how to access this data structure; complex nesting of arrays within arrays can be hard to manage and lead to bugs. Make sure your needs aren't better solved by another data structure, or a custom class.
Yes. You can use the following (enormous) line of code:
NSMutableArray * completeArray =
[NSMutableArray arrayWithArray:
[[myArray objectAtIndex:0] arrayByAddingObjectsFromArray:
[myArray objectAtIndex:1]]];
edit: Assuming that myArray
is defined as follows:
NSArray * stringArray = [NSArray arrayWithObjects:
@"one", @"two", @"three", nil];
NSArray * otherArray = [NSArray arrayWithObjects:
someObj, otherObj, thirdObj, nil];
NSArray * myArray = [NSArray arrayWithObjects:
stringArray, otherArray, nil];
The line of code I posted above will give you one big NSMutableArray
which contains:
@"one, @"two", @"three", someObj, otherObj, thirdObj