Note that Objective-C collection classes can only hold objects, so I have assumed your input numbers are held in NSNumber
objects. This also means that the CGPoint
struct
s must be held in a NSValue
object in the combined array:
NSArray *array1 = ...;
NSArray *array2 = ...;
NSMutableArray *pointArray = [[NSMutableArray alloc] init];
if ([array1 count] == [array2 count])
{
NSUInteger count = [array1 count], i;
for (i = 0; i < count; i++)
{
NSNumber *num1 = [array1 objectAtIndex:i];
NSNumber *num2 = [array2 objectAtIndex:i];
CGPoint point = CGPointMake([num1 floatValue], [num2 floatValue]);
[pointArray addObject:[NSValue valueWithCGPoint:point]];
}
}
else
{
NSLog(@"Array count mis-matched");
}