Objective-C: -[NSString wordCount]

后端 未结 7 1183
孤街浪徒
孤街浪徒 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 22:10

    Swift 3:

    let words: [Any] = (string.components(separatedBy: " "))
    let count = words.count
    

提交回复
热议问题