How to translate this enum from objective-c to swift? -
i don't understand why & , << don't work in swift. please me translate objective-c code examples swift.
example 1
uiviewcontroller *viewcontroller = [[uiviewcontroller alloc] init]; viewcontroller.edgesforextendedlayout = uirectedgebottom | uirectedgetop; if (viewcontroller.edgesforextendedlayout & uirectedgebottom) { nslog(@"got it!"); }
i'am trying translate in swift got error
let viewcontroller = uiviewcontroller() viewcontroller.edgesforextendedlayout = .bottom | .top if viewcontroller.edgesforextendedlayout & .bottom { println("got it!") }
example 2
typedef ns_options(nsinteger, kviewcontrolleranchoredgesture) { kviewcontrolleranchoredgesturenone = 0, kviewcontrolleranchoredgesturepanning = 1 << 0, kviewcontrolleranchoredgesturetapping = 1 << 1, kviewcontrolleranchoredgesturecustom = 1 << 2, kviewcontrolleranchoredgesturedisabled = 1 << 3 };
here can't understand why << doesn't compile, how can fix it?
enum kviewcontrolleranchoredgesture: nsinteger { case none = 0 case panning = 1 << 0 case tapping = 1 << 1 case custom = 1 << 2 case disabled = 1 << 3 }
thanks in advance!
first:
let viewcontroller = uiviewcontroller() viewcontroller.edgesforextendedlayout = .bottom | .top if viewcontroller.edgesforextendedlayout & .bottom == .bottom { println("got it!") }
second:
in swift rawoptionsettype
used instead of ns_options
. there no official guide find, here nice article: http://nshipster.com/rawoptionsettype/
Comments
Post a Comment