2014-01-15 72 views
3

如何檢測NSString是否包含下圖所示的NSTextAttachment [OBJ]?如何檢測NSString是否包含NSTextAttachment圖像?

記錄文本除純文本外不顯示任何內容。

NSLog(@" Message: %@", message); 

我設法與將其刪除:

NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] invertedSet]; 
NSString *resultString = [[conversation.lastMessage componentsSeparatedByCharactersInSet:notAllowedChars] componentsJoinedByString:@""]; 

但感覺更像是一個黑客不是真正的解決方案。我真的很驚訝,它甚至顯示出來,因爲該消息是NSString類的實例...

enter image description here

+1

掃描字符值0xfffc。 –

回答

2

文本附件文本與NSAttachmentCharacter總是相關聯。這是不可打印的,這就是爲什麼你不在日誌中看到它。但您可以搜索並刪除它。

0

NSLog%@引用的對象上調用description選擇器,因此即使對於不是字符串的對象,也會打印字符串。