Consider the following code
NSString *param_string @"1:3:6:10:15:22:28:30";
NSArray *params = [param_string componentsSeparatedByString:@":"];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterNoStyle];
NSMutableArray *convertedArray = [[NSMutableArray alloc] initWithCapacity:[params count]];
for(int i = 0; i < [params count]; i++){
[convertedArray insertObject:[formatter numberFromString:[params objectAtIndex:i] atIndex:i]];
}
Is there a better, more efficient way of achieving this? The initial param_string could be longer in practice but I don't expect there to ever be more than approximately 200 elements in the params array.
Thanks