saving an item of an array to a different array
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 dif开发者_高级运维ferent array).
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.)
精彩评论