• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: supportedInterfaceOrientations in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: supportedInterfaceOrientations in Swift


  • Subject: Re: supportedInterfaceOrientations in Swift
  • From: Greg Parker <email@hidden>
  • Date: Fri, 20 Jun 2014 11:31:13 -0700

On Jun 19, 2014, at 5:39 PM, Roland King <email@hidden> wrote:
> On 20 Jun, 2014, at 5:04 am, Greg Parker <email@hidden> wrote:
>>>
>>> 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.
>>
>> Please file a bug report. -supportedInterfaceOrientations should be declared to return UIInterfaceOrientationMask, not Int. This sort of loose typing works in C but not in Swift.
>
> OK I've filed (rdar://17387641) - although in this case I'm not sure it would have made life much better as the constructor takes a UInt the best I would have been able to do is
>
> 	return UIInterfaceOrientationMask( UIInterfaceOrientationMask.Portrait.value + UIInterfaceOrientationMask.PortraitUpsideDown.value )
>
> which isn't much prettier. I do agree however that returning a UIIntefaceOrientationMask  would be semantically better and it's not hard to define the '+' and '|' operators on them myself to do the right thing which would lead to
>
> 	return UIInterfaceOrientationMask.Portrait + UIInterfaceOrientationMask.PortraitUpsideDown
>
> which would be very nice (and i suggested in the radar)

The | operator should already work with UIInterfaceOrientationMask and anything else declared with NS_OPTIONS in Objective-C headers. It would look like this if -supportedInterfaceOrientations returned UIInterfaceOrientationMask:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
  return UIInterfaceOrientationMask.Portrait | UIInterfaceOrientationMask.PortraitUpsideDown
}

…which is perfectly fine.


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


References: 
 >supportedInterfaceOrientations in Swift (From: Roland King <email@hidden>)
 >Re: supportedInterfaceOrientations in Swift (From: Greg Parker <email@hidden>)
 >Re: supportedInterfaceOrientations in Swift (From: Roland King <email@hidden>)

  • Prev by Date: Re: Advice on document handling
  • Next by Date: Re: Advice on document handling
  • Previous by thread: Re: supportedInterfaceOrientations in Swift
  • Next by thread: NSReleasePool issue
  • Index(es):
    • Date
    • Thread