[英]How to stop enumerating attributes of a NSAttributedString?
In the documentation of the enumerateAttribute
method it is said, regarding the stop
argument of the block, that: 在
enumerateAttribute
方法的文档中,关于块的stop
参数,可以说:
The block can set the value to true to stop further processing of the set.
该块可以将值设置为true以停止对该设置的进一步处理。
However, inside the block the stop
argument is a let
and I can't set it to true
. 但是,在块内,
stop
参数是一个let
,我无法将其设置为true
。
I need to stop enumerating after the first attribute occurrence found. 找到第一个属性出现后,我需要停止枚举。 How could I do that?
我该怎么办?
The parameter is a reference that holds the actual value: 该参数是保存实际值的参考:
let attributed: NSAttributedString = ...
attributed.enumerateAttribute(
NSFontAttributeName,
in: NSRange(location: 0, length: attributed.length),
options: []
) { value, range, stop in
stop.pointee = true
}
See the reference for UnsafeMutablePointer . 请参见UnsafeMutablePointer的参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.