• 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: Roland King <email@hidden>
  • Date: Fri, 20 Jun 2014 08:39:00 +0800

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)

>
>>
>> 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
>
> The last should work assuming `a` is not negative.
>

Ah it does - when I compile and run it - it doesn't work in a playground because a playground with the following code and nothing else in it

	let a = 123
	let b = UInt( a )

crashes with

	fatal error: Can't unwrap Optional.none

when it's trying to format the output for writing. In fact it seems lots of my 'failed experiments' from yesterday were just the playground crashing. (rdar://17387985). The command-line REPL works fine.

Thanks for the reply.
_______________________________________________

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


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

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