Last active
December 23, 2018 10:38
-
-
Save NunoAlexandre/c36d7241e3b45d65d36a966aaa7ab893 to your computer and use it in GitHub Desktop.
Procedural modeling
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
class Slideshow: UIViewController { | |
let slides: [SlideView] | |
init(slides: [SlideView]) { | |
self.slides = slides | |
} | |
// UI & Layout code goes here... | |
} | |
class SlideView: UIView { | |
let title: String | |
let description: String | |
let image: UIImage | |
init(index: Int) { | |
self.title = SlideView.getTitle(index)! | |
self.description = SlideView.getDescription(index)! | |
self.image = SlideView.getImage(index)! | |
} | |
private static func getTitle(_ index: Int) -> String? { | |
switch index { | |
case 0: | |
return "Bobby Mcferrin" | |
case 1: | |
return "Kurt Vile" | |
case 2: | |
return "The War on Drugs" | |
default: | |
return nil | |
} | |
} | |
private static func getDescription(_ index: Int) -> String? { | |
switch index { | |
case 0: | |
return "Jazz at its best" | |
case 1: | |
return "A prolific creative" | |
case 2: | |
return "An American indie rock band from Philadelphia" | |
default: | |
return nil | |
} | |
} | |
private static func getImage(_ index: Int) -> UIImage? { | |
switch index { | |
case 0: | |
return UIImage(named: "BobbyMcFerrin") | |
case 1: | |
return UIImage(named: "KurtVile") | |
case 2: | |
return UIImage(named: "TheWarOnDrugs") | |
default: | |
return nil | |
} | |
} | |
// UI & Layout code goes here... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment