Ios 如何检查字符串是否包含NSattributedstring

Ios 如何检查字符串是否包含NSattributedstring,ios,nsattributedstring,Ios,Nsattributedstring,我已经通过添加NSattributedstring将图像添加到textview的文本中 用户可以编辑文本视图 如何检查textview的文本是否仍包含NSAttributed字符串 借 我如何检查它?使用此代码, 从..那里得到了精细的代码 NSLog用于阵列 array: ( Good, "\Ufffc", Image ) NSLog对于布尔变量 contianImage: NO contianImage: YES contianImage: NO 这是我添加的图像

我已经通过添加NSattributedstring将图像添加到textview的文本中

用户可以编辑文本视图

如何检查textview的文本是否仍包含NSAttributed字符串

我如何检查它?

使用此代码,
从..那里得到了精细的代码

NSLog
用于阵列

array: (
    Good,
    "\Ufffc",
    Image
)
NSLog
对于布尔变量

contianImage: NO
contianImage: YES
contianImage: NO
这是我添加的图像,

对于您的代码,它也可以工作,
检查使用您的代码生成的我的日志,

2016-06-16 12:52:15.030 Imagetest[2394:109009] array: (
    "
\n
\Ufffc"
)
2016-06-16 12:52:15.031 Imagetest[2394:109009] contianImage: YES

如果添加
NSAttributedString
,则知道它的范围。您可以检查该范围是否仍有属性。textView.attributedText-length将返回其中的所有字符串数。如何检查属性?检查其
attributedText
?您可以使用从
0
contentView.attributedText.length originalAttributedText.length的for循环,并使用
attributedSubstringFromRange:
并与
IsequalAttributedString:
进行比较。不要忘记对范围进行必要的检查(contentView.attributedText.lengtharray: ( Good, "\Ufffc", Image )
contianImage: NO
contianImage: YES
contianImage: NO
2016-06-16 12:52:15.030 Imagetest[2394:109009] array: (
    "
\n
\Ufffc"
)
2016-06-16 12:52:15.031 Imagetest[2394:109009] contianImage: YES