Created
December 22, 2015 21:06
-
-
Save jemmons/cc5240858590566436ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let attr = NSAttributedString(string: "Hello, playground", attributes: [NSBackgroundColorAttributeName:UIColor.redColor()]) | |
var shouldBeOne = 1 | |
attr.enumerateAttribute(NSBackgroundColorAttributeName, inRange: NSMakeRange(0, attr.length), options:[]) { (value, range, stop) -> Void in | |
shouldBeOne += 1 | |
} | |
print(shouldBeOne) //<- prints "1" | |
var shouldBeZero = 0 | |
attr.enumerateAttribute("not a real attribute", inRange: NSMakeRange(0, attr.length), options:[]) { (value, range, stop) -> Void in | |
shouldBeZero += 1 | |
} | |
print(shouldBeZero) //<- prints "1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment