NSArray *tLines = [[NSArray alloc] initWithObjects:
[[NSArray alloc] initWithObjects:@"Matt", @"David", nil],
[[NSArray alloc] initWithObjects:@"Bob", @"Ken", nil], nil];
self.lines = tLines;
[tLines release];
I’m allocing NSArrays within an NSArray, will the nested arrays get released when I call [lines release];?
No, you should not do this. When you
allocthe arrays, you need to release them. The containing array will handle memory management for its objects (retaining them when they’re added, releasing when they’re removed), but that is beside the responsibility of the object that created to the arrays to properly release them. You should either use a convenience constructor to create the arrays or else create them one at a time and release them after they’ve been added to the master array.