Search code examples
iphoneiosobjective-cemojiunichar

Display emogi icon in unichar with string


In my application i want to display emoji icon with string but its giving me syntax error.

It's displays below string successfully

unichar character = 0xE116;
self.uniCharStr =[NSString stringWithCharacters:&character length:1];

But its giving syntax error while i use value as following.

unichar character = &#x1f4a1
self.uniCharStr =[NSString stringWithCharacters:&character length:1];

I have get this values from emoji icon list from this link.

Can anyone please guide me where i m wrong ?

Thanks!


Solution

  • Try \U0001F4A1 instead of &#x1f4a1

    You should replace &#x withU000 also dont forget to add an escape sequence.

    Edit :

    To display the emoji in a label, I use the following code.

    label.text = [NSString stringWithFormat:@"%@", @"\U0001f4a1"];