Skip to content

Instantly share code, notes, and snippets.

@AndreyPanov
Last active May 24, 2016 07:50
Show Gist options
  • Save AndreyPanov/2b588c773f2b56460f21282d33541a21 to your computer and use it in GitHub Desktop.
Save AndreyPanov/2b588c773f2b56460f21282d33541a21 to your computer and use it in GitHub Desktop.
Using unwrap images in project
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