Skip to content

Instantly share code, notes, and snippets.

@natecook1000
Created November 3, 2014 21:05
Show Gist options
  • Select an option

  • Save natecook1000/9e32a5067038791f3dab to your computer and use it in GitHub Desktop.

Select an option

Save natecook1000/9e32a5067038791f3dab to your computer and use it in GitHub Desktop.
Using ObjC-defined NS_OPTIONS in Swift
// objective-c:
typedef NS_OPTIONS(NSInteger, MesozoicPeriod) {
MesozoicPeriodTriassic,
MesozoicPeriodJurassic,
MesozoicPeriodCretaceous
};
// Swift
let period: MesozoicPeriod = MesozoicPeriod.Jurassic
let period2 = MesozoicPeriod.Jurassic | MesozoicPeriod.Cretaceous
if (period2 & MesozoicPeriod.Jurassic != nil) {
println("Jurassic")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment