How to split an NSArray into two equal pieces?
I have an NSArray, and I want to split it into two equal pieces (if odd "count" then add to the latter new array) - I want to split it "down the middle" so to speak. The following code does exactly what I want, but is there a better way?: // NOTE: `NSArray testableArray` is an NSArray of objects from a class defined elsewhere; NSMutableArray *leftArray = [[NSMutableArray alloc] init]; NSMutableArray *rightArray = [[NSMutableArray alloc] init]; for (int i=0; i < [testableArray count]; i=i+1) { if (i < [testableArray count]/2) { [leftArray addObject:[testableArray objectAtIndex:i]]; } else {