开发者

Split before and after every , in a string and add to array

Basically i want to split out everything inbetween the commas and add to an array and then get the count of this array and return it too.

I know its a mouthfull but someone will understand :P

Thanks

Maso开发者_JS百科n


use componentsSeparatedByString:


Use this one:

-(NSInteger)countTotalWord:(NSString *) localString{
    //NSString *localString = @"My, Name, Is,Sudesh,Kumar ";
    //NSMutableArray *simplefyWordArray = [[NSMutableArray alloc] init];
    NSArray *wordSet = [localString  componentsSeparatedByString:@","];
   //for (int i=0 ;i<[wordSet count]; i++) {
       //NSString *trimedString = [[wordSet objectAtIndex:i] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
       //[simplefyWordArray appendFormat:@"%@+",trimedString];
    //}
    return [wordSet count];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜