次のコードを試しました:
NSArray *yourArray = [NSArray arrayWithObjects:@"TB3257 TB3258", @"TB3259 TB3260", @"TB3261 TB3262", @"TB3263 TB3259", @"TB3257 TB3258 TB3258", @"TB3260 TB3261", nil];
NSMutableArray *firstArray = [NSMutableArray array];
NSMutableArray *secondArray = [NSMutableArray array];
NSMutableArray *thirdArray = [NSMutableArray array];
for (int i = 0; i < [yourArray count]; i++) {
NSArray *tempArray = [[yourArray objectAtIndex:i]componentsSeparatedByString:@" "];
[firstArray addObject:[tempArray objectAtIndex:0]];
[secondArray addObject:[tempArray objectAtIndex:1]];
if ([tempArray count] == 3) {
[thirdArray addObject:[tempArray objectAtIndex:2]];
}
}
NSLog(@"yourArray: %@\nfirst: %@\nsecond: %@\nthird: %@", yourArray, firstArray, secondArray, thirdArray);
出力は次のとおりです。
yourArray: (
"TB3257 TB3258",
"TB3259 TB3260",
"TB3261 TB3262",
"TB3263 TB3259",
"TB3257 TB3258 TB3258",
"TB3260 TB3261"
)
first: (
TB3257,
TB3259,
TB3261,
TB3263,
TB3257,
TB3260
)
second: (
TB3258,
TB3260,
TB3262,
TB3259,
TB3258,
TB3261
)
third: (
TB3258
)
それが役に立てば幸い