lets say we have a simple array with file 1, file 2, file 3. and we are displaying a controller with file 1, how can we write file 1 from the original array to a new and completely different array (lets call it different array).
A:
NSArray *newArray = [NSArray arrayWithObject:[oldArray objectAtIndex:1]];
Edit: to answer the comment:
NSArray *bigArray = [NSArray arrayWithObjects:newArray1, newArray2, nil];
Now on a style note, you realize the first code line makes an array with only 1 object in it? there is really no need to create that array. you can simply reference the object you need from your original array, and if you wanted to put multiple objects into the bigArray you could. (You are creating an extra layer of NSArray that it doesn't look like is needed at all.)
Jesse Naugher
2010-08-17 14:41:49
ok lets say if i make one more of these arrays how can i make a superclass that includes both of these arrays.lets say if i want to include more newArrays into one bigArray
Alx
2010-08-17 19:11:36
edited to answer your comment.
Jesse Naugher
2010-08-17 19:21:35
ok wait i got confused i want this array to be able to save items at tableview didselectindexpath path.i keep getting crashes using this code NSMutableArray *favorites = [NSMutableArray addObject:[myList objectAtIndex:1]];how should i proceed in adding individuals items to a larger array to load favorites?
Alx
2010-08-18 08:47:58