0

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.

Bill L
  • 2,576
  • 4
  • 28
  • 55
  • I am sure there is a duplicate question but I can't find it now. – Sulthan Mar 17 '17 at 14:11
  • 1
    `stop.pointee = true`? http://stackoverflow.com/questions/24214136/how-to-stop-enumerateobjectsusingblock-swift and http://stackoverflow.com/questions/41547030/how-to-stop-enumerating-attributes-of-a-nsattributedstring – Larme Mar 17 '17 at 14:11
  • 1
    `stop.memory = true` seems to be Swift2. – Larme Mar 17 '17 at 14:12

0 Answers0