How do I declare an array of arrays in Objective-C?
            Asked
            
        
        
            Active
            
        
            Viewed 3,101 times
        
    2
            
            
        - 
                    If you're very new to programming, asking questions on Stack Overflow is not the place you need to be. You should find a good book or a series of online tutorials. Have a look at [Good resources for learning ObjC](http://stackoverflow.com/q/1374660). The Big Nerd Ranch books are excellent, and lots of people like the Stanford iOS course on iTunes U. Good luck! – jscs Feb 24 '14 at 03:28
3 Answers
2
            
            
        NSArray *arrayOfArrays = [NSArray arrayWithObjects:
              [NSArray arrayWithObjects:@"Hello!", @"My", @"name", @"is", nil],
              [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil], nil];
 
    
    
        waterproofpiano
        
- 73
- 10
2
            
            
        Assume you have the objects obj1,obj2,...,obj9
Then this would create an array containing three members:
NSArray *array = @[obj1,obj2,obj3];
And this would create an array of arrays, each containing three members:
NSArray *array = @[ @[obj1,obj2,obj3], @[obj4,obj5,obj6], @[obj7,obj8,obj9] ];
 
    
    
        Pétur Ingi Egilsson
        
- 4,368
- 5
- 44
- 72
 
    