如何停止枚举NSAttributedString的属性?
在enumerateAttribute
方法的文档中,关于块的stop
参数,说:
该块可以将该值设置为true以停止对该集合的进一步处理。
但是,在块内stop
参数是一个let
我不能把它设置为true
。
在发现第一个属性发生之后,我需要停止枚举。 我怎么能这样做?
该参数是保存实际值的参考:
let attributed: NSAttributedString = ... attributed.enumerateAttribute( NSFontAttributeName, in: NSRange(location: 0, length: attributed.length), options: [] ) { value, range, stop in stop.pointee = true }
请参阅UnsafeMutablePointer的参考。