Last active
September 28, 2017 14:45
-
-
Save AltiAntonov/f0f86e7cd04c61118e13f753191b5d9e to your computer and use it in GitHub Desktop.
Convert attributes [Stirng: Any] to Swift 4 attributes [NSAttributedStringKey: Any]
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
public extension Dictionary { | |
func toNSAttributedStringKeys() -> [NSAttributedStringKey: Any] { | |
var atts = [NSAttributedStringKey: Any]() | |
for key in keys { | |
if let keyString = key as? String { | |
atts[NSAttributedStringKey(keyString)] = self[key] | |
} | |
} | |
return atts | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment