Last active
May 24, 2016 07:50
-
-
Save AndreyPanov/2b588c773f2b56460f21282d33541a21 to your computer and use it in GitHub Desktop.
Using unwrap images in project
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
protocol AssetLoadable { | |
var rawValue: String { get } | |
func imageNamed() -> String | |
} | |
extension AssetLoadable { | |
func imageNamed() -> String { | |
return rawValue | |
} | |
} | |
enum EmptyImages: String, AssetLoadable { | |
case NoInternet = "empty_Internet" | |
case NoItems = "empty_Items_icon" | |
} | |
extension UIImage { | |
convenience init!(_ assetIdentifier: AssetLoadable) { | |
self.init(named: assetIdentifier.imageNamed()) | |
} | |
} | |
//in project | |
//let image = UIImage(EmptyImages.NoInternet) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment