質問

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!

役に立ちましたか?

解決

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"];

他のヒント

try this hope this will help you.

NSString *emojiStr  = [NSString stringWithFormat:@"(%@)", @"0xE116"];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top