Objective-C: -[NSString wordCount]

后端 未结 7 1204
孤街浪徒
孤街浪徒 2020-12-05 21:39

What\'s a simple implementation of the following NSString category method that returns the number of words in self, where words are separated by an

7条回答
  •  醉酒成梦
    2020-12-05 21:56

    - (NSUInteger) wordCount
    {
       NSArray *words = [self componentsSeparatedByString:@" "];
       return [words count];
    }
    

提交回复
热议问题