formatting NSArray
- by califguy
So from the code below, I have managed to get the string *tempstring into an array chunk. Now chunk[0] contains 'a' while chunk[1] contains 'aa'. I am trying to format chunk[0] to '0a' which I can using the replaceObjectAtIndex method. Here's my question: How do I detect that chunk[0] is formatted as 'a' and not '0a'. I want to check all the indexes and make sure they have double digits and if not use a 0 to prefix it.
NSString *tempstring = @"a-aa-bb";
NSMutableArray *chunk = [tempstring componentsSeparatedByString: @"-"];
NSLog(@"%@",[chunk objectAtIndex:0]);