gpt4 book ai didi

ios - 如何停止枚举 NSAttributedString 的属性?

转载 作者:行者123 更新时间:2023-11-30 12:36:06 25 4
gpt4 key购买 nike

enumerateAttribute 方法的文档中,关于 block 的 stop 参数,指出:

The block can set the value to true to stop further processing of the set.

但是,在 block 内,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 的引用.

关于ios - 如何停止枚举 NSAttributedString 的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42859698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com