Created
December 16, 2014 22:07
-
-
Save davidortinau/de6c2eab6929fc9b3745 to your computer and use it in GitHub Desktop.
NSDictionary Obj-C to Swift
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
// attempt to recreate the dictionary in Swift | |
var style:[String:NSDictionary] = [ | |
"$default" : [NSFontAttributeName : UIFont(name: "Raleway", size: 12)], | |
"strong" : [NSFontAttributeName : UIFont(name: "Raleway-Bold", size: 12)], | |
"h1" : [NSFontAttributeName : UIFont(name: "Raleway-Bold", size: 14)] | |
] | |
// use as an NSDictionary fails at runtime | |
style._bridgeToObjectiveC() as NSMutableDictionary |
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
NSDictionary *style = @{ | |
@"$default" : @{NSFontAttributeName : [UIFont fontWithName:@"Raleway" size:12]}, | |
@"strong" : @{NSFontAttributeName : [UIFont fontWithName:@"Raleway-Bold" size:12]}, | |
@"h1" : @{NSFontAttributeName : [UIFont fontWithName:@"Raleway-Bold" size:14]} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment