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];
}
精彩评论