If you launch TextEdit and choose Emoji & Symbols under Edit, you will have a list of 291 symbols for Smileys and People under Sierra (macOS 10.12). And I want to list all these 291 emoji symbols with NSCollectionView
. Now, I have a string consisting of 291 emoji symbols. And I separate them to create an array as follows.
class SmileyViewController: NSViewController, NSCollectionViewDelegate, NSCollectionViewDataSource {
// MARK: - Variables
var emojiArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
let emojiString = "..." // 291 symbols
emojiArray = emojiString.characters.map { String($0) }
print(emojiArray.count) // 408, not 291
collectionView.reloadData()
}
}
Running the code above, the array that I get actually contains 408 symbols. If I take a close look, some of them separate themselves into three symbols. For example, a symbol named man with blonde hair turns itself into three symbols. One of them is a gender symbol. this topic suggests that a single emoji symbol may be a combination of a few or more symbols. Is there something that I can do to separate this particular string containing 291 symbols into an array containing 291 symbols? Thanks.