Skip to content

Instantly share code, notes, and snippets.

@susieyy
Created January 14, 2017 02:45
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 susieyy/ca18fe34127194ebd7284ec85f5271f2 to your computer and use it in GitHub Desktop.
Save susieyy/ca18fe34127194ebd7284ec85f5271f2 to your computer and use it in GitHub Desktop.
#swtws
enum ProfileDisplayType {
case mine
case other(userId :Int)
var title: String {
switch self {
case .mine: return "My profile"
case .other(_): return "\(userRealm.name)'s pofile"
}
}
var userRealm: UserRealm {
switch self {
case .mine: return try! Realm().objectForPrimaryKey(UserRealm.self, key: Shared.mineId)!
case .other(let userId): return try! Realm().objectForPrimaryKey(UserRealm.self, key: userId)!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment