This method can be used to detect and return a bool value.
-(BOOL) Stringcontainsemoji: (NSString *)string{__block BOOL returnvalue=NO; [stringEnumeratesubstringsinrange:nsmakerange (0, [stringlength]) Options:nsstringenumerationbycomposedcharactersequences Usingblock:^ (NSString *substring, Nsrange substringrange, Nsrange enclosingrange, BOOL *stop) { ConstUnichar HS = [substring Characteratindex:0]; if(0xd800<= HS && HS <=0XDBFF) { if(Substring.length >1) { ConstUnichar ls = [substring characteratindex:1]; Const intUC = (HS-0xd800) *0x400) + (LS-0xdc00) +0x10000; if(0x1d000<= UC && UC <=0x1f77f) {returnvalue=YES; } } } Else if(Substring.length >1) { ConstUnichar ls = [substring characteratindex:1]; if(ls = =0x20e3) {returnvalue=YES; } } Else { if(0x2100<= HS && HS <=0x27ff) {returnvalue=YES; } Else if(0x2b05<= HS && HS <=0x2b07) {returnvalue=YES; } Else if(0x2934<= HS && HS <=0x2935) {returnvalue=YES; } Else if(0x3297<= HS && HS <=0x3299) {returnvalue=YES; } Else if(HS = =0xa9|| HS = =0xae|| HS = =0x303d|| HS = =0x3030|| HS = =0x2b55|| HS = =0x2b1c|| HS = =0x2b1b|| HS = =0x2b50) {returnvalue=YES; } } }]; returnreturnvalue; }
This method can be added to the classification of the nsstring, or directly affixed to the current controller, in the upcoming text, or to click on the text to be sent to judge, you can use the bomb alertview to remind the re-input
This method is also found on the Internet, the specific source does not remember
Detects if the text inside the TextView contains emoji emoji characters