How to separate emojis entered (through default keyboard) on textfield

后端 未结 2 1340
半阙折子戏
半阙折子戏 2020-12-10 18:03

I entered a two emojis in textfield

相关标签:
2条回答
  • 2020-12-10 18:28

    Update for Swift 4 (Xcode 9)

    As of Swift 4 (tested with Xcode 9 beta) a "Emoji ZWJ Sequence" is treated as a single Character as mandated by the Unicode 9 standard:

    let str = "                                                                    
    0 讨论(0)
  • 2020-12-10 18:36

    You can use this code example or this pod.

    To use it in Swift, import the category into the YourProject_Bridging_Header

    #import "NSString+EMOEmoji.h"
    

    Then you can check the range for every emoji in your String:

    let example: NSString = "                                                                    
    0 讨论(0)
提交回复
热议问题