开发者

I have a class where data of strings have been stored

I have a class where data of strings have been stored.

void testCallback(char *data)
{
    NSLog(@"%s", data);
}

in the log it displays the following output,

1.00 2.00 3.00

4.00 5.00 6.00

But i need the output in the following manner,

2.00,3.00

5.00,6.00

so i want开发者_运维问答 to remove first character and i want to replace the space between the 2nd and 3rd with the comma(,).How can i do this.


Already i answered Link Here

void testCallback(char *data)   
{   
  NSString *str=[NSString stringWithFormat:@"%s",data];
  NSArray *split = [str componentsSeparatedByString:@" "];
  NSString *replacevalue=@" ";
    for(int i=1;i<[split count];i++)
     {
       if([replacevalue isEqualToString:@" "])
         replacevalue=[NSString stringWithFormat:@"%@",[split objectAtIndex:i]];
       else
         replacevalue=[NSString stringWithFormat:@"%@,%@",replacevalue,[split objectAtIndex:i]];
     }

    NSLog(@"%@",replacevalue);  
}


Conver you Char *array to the NSString. than you can use the method for replacing ReplaceWithAccrunce: and you can concate with NSStrings Method,also..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜