Skip to content

Instantly share code, notes, and snippets.

@jakemarsh
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakemarsh/913c5d55dff53eb17f56 to your computer and use it in GitHub Desktop.
Save jakemarsh/913c5d55dff53eb17f56 to your computer and use it in GitHub Desktop.
little-bites-of-cocoa-002-chainable-methods
enum CountdownType: Int { case ToTheSecond, ToTheDay }
enum ColorScheme: Int { case AfterMidnight, ClassyYellow, Tealfish }
class Concern {
var title: String = ""
func title(aTitle: String?) -> Concern { title = aTitle ?? ""; return self }
var subtitle = ""
func subtitle(aSubtitle: String?) -> Concern { subtitle = aSubtitle ?? ""; return self }
var countdownType: CountdownType = .ToTheSecond
func countdownType(type: CountdownType) -> Concern { countdownType = type; return self }
var colorScheme: ColorScheme = .AfterMidnight
func colorScheme(scheme: ColorScheme) -> Concern { colorScheme = scheme; return self }
}
Concern()
.title("Big Meeting")
.subtitle("With those people from that place")
.countdownType(.ToTheDay)
.colorScheme(.Tealfish)
Event
.withCategory(.Meeting)
.withAttendees([User.me])
.sort { $0.startDate < $1.startDate }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment