基本上我想在逗号之间拆分所有内容并添加到数组中,然后获取该数组的计数并返回它。
我知道它满口但有人会理解:P
由于
梅森
答案 0 :(得分:5)
使用componentsSeparatedByString:
答案 1 :(得分:0)
使用这个:
-(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];
}