Prashant Ghimire Prashant Ghimire - 2 months ago 20
Swift Question

use emoji in label from ios default keyboard

i want to use text input and emoji from iOS default keyboard and send it to server and show that text to label but i am not able to display only display text but not emojis.
if i do it locally than it will display emoji.

self.labelName.text = TextFiled.text

output : "test


When send a data to server use this method .

let data1 = txtMessage.text.dataUsingEncoding(NSNonLossyASCIIStringEncoding)!
let finalmessage = String(data: data1, encoding: NSUTF8StringEncoding)

when you get a response from server before set in label use this method.

 let trimmedString = YOURSERVER_RESPONSE_STRING.stringByTrimmingCharactersInSet(
 let data2 = trimmedString.dataUsingEncoding(NSUTF8StringEncoding)!
 let messagestring = String(data: data2, encoding: NSNonLossyASCIIStringEncoding)
 YOURLABEL.text = messagestring as String

Try this your problem solve.