Last active
April 12, 2017 23:38
-
-
Save natebirkholz/aff9a124b2a71a492d00c7744800be99 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
let attributes = [ NSForegroundColorAttributeName : self.view.tintColor ] | |
let attributedString = NSAttributedString(string: NSLocalizedString("Sign In", comment: ""), attributes: attributes) | |
warns: (Expression implicitly coerced from 'UIColor?' to Any) | |
right way: | |
let attributes: [ String : UIColor ] | |
if let maybeAttributes = [ NSForegroundColorAttributeName : self.view.tintColor ] { | |
attributes = maybeAttributes | |
} else { | |
assertionFailure("self.view.tintColor is nil") | |
} | |
how it will be: | |
let attributes = [ NSForegroundColorAttributeName : self.view.tintColor! ] | |
let attributedString = NSAttributedString(string: NSLocalizedString("Sign In", comment: ""), attributes: attributes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment