For some reason, I"m not able to set the stop
parameter in NSAttributedString
's enumerateAttributes(in:options:using:)
function. Here's my code:
attributedText.enumerateAttributes(in: NSRange(location: 0, length: self.text?.characters.count ?? 0), options: []) {
(attributes, _, stop) in
var clearTypography = false
for (key, _) in attributes {
// If either font or textColor are set on the label,
// update both and break out. The attributedText
// will override the relevant properties once we set
// it
if key == NSFontAttributeName || key == NSForegroundColorAttributeName {
clearTypography = true
stop = true
break
}
}
However, on the line where I'm setting stop = true
I get the error Cannot assign to value: 'stop' is a 'let' constant
. I've tried stop.memory = true
to get the same error.
Any idea why I'm not able to assign to the variable? It's stated purpose is to stop the enumeration when it's assigned to true
, so I have to imaging I'm just missing something here.