Detecting Emoji characters in Swift

I recently had to write some code to check for the presence of Emoji characters in a UITextField in Swift. I tried a few approaches before arriving at the conclusion below. Credit to Ziewvater for helping.

Adding this code as an extension to String makes useage simple: “string”.containsEmoji()

That’s it!

 

Leave a comment