formatting NSArray

Posted by califguy on Stack Overflow See other posts from Stack Overflow or by califguy
Published on 2010-03-18T07:23:42Z Indexed on 2010/03/18 7:41 UTC
Read the original article Hit count: 311

Filed under:
|
|

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]); 

© Stack Overflow or respective owner

Related posts about nsarray

Related posts about nsstring