Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何检测NSString是否包含NSTextAttachment映像?_Ios_Objective C_Nsstring_Nstextattachment - Fatal编程技术网

Ios 如何检测NSString是否包含NSTextAttachment映像?

Ios 如何检测NSString是否包含NSTextAttachment映像?,ios,objective-c,nsstring,nstextattachment,Ios,Objective C,Nsstring,Nstextattachment,我如何检测NSString是否包含下图所示的NSTextAttachment[OBJ] 记录文本不会显示除纯文本以外的任何内容 NSLog(@" Message: %@", message); 我用以下方法删除了它: NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

我如何检测
NSString
是否包含下图所示的
NSTextAttachment
[OBJ]

记录文本不会显示除纯文本以外的任何内容

NSLog(@" Message: %@", message);
我用以下方法删除了它:

NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] invertedSet];
NSString *resultString = [[conversation.lastMessage componentsSeparatedByCharactersInSet:notAllowedChars] componentsJoinedByString:@""];
但这更像是一种黑客行为,而不是真正的解决方案。我真的很惊讶它竟然出现了,因为消息是
NSString
类的一个实例


文本附件始终与文本中的NSAttachmentCharacter相关联。它无法打印,这就是为什么您在日志中看不到它的原因。但是您可以搜索并删除它。

NSLog
%@
引用的对象上调用
说明
选择器,因此它甚至可以打印字符串,即使对象不是字符串。

扫描字符值0xfffc。