I'm overriding supportedInterfaceOrientations in my view controller because I want it to return Portrait + PortraitUpsideDown, and on iPhone PortraitUpsideDown is not included in the standard return.
The Objective-C method would look something like this -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; } Swift has stubbed out the method thus override func supportedInterfaceOrientations() -> Int { } which makes some sense. I'm tripping over myself trying however to return the correct Int without casting my casts to casts of casts. UIInterfaceOrientationMask is a struct with a number of Type properties, so you can write UIInterfaceOrientationMask.Portrait to get its value however that's a struct so you need to ask for the 'value' property, which is defined to return a UInt and seems to do the same as toRaw(). Trying to return UIInterfaceOrientationMask.Portrait.value however gives the error 'NSNumber is not a subtype of Int' Odd as I thought UInt was a basic type like Int, but clearly it's an NSNumber. A bit of luck with autocompletion threw up the asSigned() method, which seems to do the same as constructing an Int using Int( .. ) That appears to work but the final line is now return UIInterfaceOrientationMask.Portrait.value.asSigned() + UIInterfaceOrientationMask.PortraitUpsideDown.value.asSigned() Surely there's something a little less unwieldy, anyone have something? Or is this just a case where Swift's strong typing meets Cocoa's C background and ends up in knots? Roland PS in the course of trying things out I tried various ways of initializing a UInt and failed dismally often with evil stack traces in the console. var a : Int = 123 var b : UInt = 123 // fail var c : UInt = a // fail var d : UInt = UInt( a ) // fail how do you even make one of these things? _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com