How to deal with emojis in iOS?

Clash Royale CLAN TAG#URR8PPP
How to deal with emojis in iOS?
I'm trying put some emojis in a text view. Most of the emojis are ok. I used Emoji example from github. When I'm putting some emojis it's string look like (When I'm debugging),

-(void)textViewDidChange:(UITextView *)textView
NSString *string = self.postTxtView.text;
string = [string stringByReplacingEmojiCheatCodesWithUnicode];
NSLog(@"%@", string);
[self.postTxtView setText:string];
How may I avoid these question mark like box? How can I get a string like :woman-heart-woman:?
:woman-heart-woman:
i edited the code
– codebot
Feb 18 '16 at 6:11
you also have to use - (NSString *)stringByReplacingEmojiCheatCodesWithUnicode; this method.
– Badal Shah
Feb 18 '16 at 6:13
I already used it!
– codebot
Feb 18 '16 at 6:17
1 Answer
1
You have to perform encoding here.
Send your string like below to server.
NSData *data1 = [vTextView.text dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *nameSubject = [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding];
Retrieve your string as emojis like below.
NSData *dataRetrive = [response[@"key"] dataUsingEncoding:NSUTF8StringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:dataRetrive encoding:NSNonLossyASCIIStringEncoding];
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
can you show your code ? what you tried ?
– Badal Shah
Feb 18 '16 at 6:04