• 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: Simple Swift question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Swift question


  • Subject: Re: Simple Swift question
  • From: Roland King <email@hidden>
  • Date: Tue, 30 Jun 2015 09:58:38 +0800

> On 30 Jun 2015, at 09:35, Rick Mann <email@hidden> wrote:
>
>
>> On Jun 29, 2015, at 16:30 , Jens Alfke <email@hidden> wrote:
>>
>> The error I get with Xcode 7 beta 2 is
>>
>> error: operand of postfix '?' should have optional type; type is 'NSURLRequest'
>>    if let req = NSURLRequest(URL: url)?
>>                 ~~~~~~~~~~~~~~~~~~~~~~^
>>
>> So it looks like this has been fixed already.
>>
>
> Strange, I'm still getting the same error after downloading beta 2. Xcode Version 7.0 beta (7A121l): "could not find an overload for 'init' that accepts the supplied arguments".
>

What’s the actual problem here, this thread baffles me

What’s wrong with

let rr = WKWebView()

if let url = NSURL(string: "some url")
{
	rr.loadRequest( NSURLRequest( URL: url ) )
}

The NSURLRequest() initializer isn’t fallible so both error messages are basically correct when you stuff a ‘?’ on the end of the NSURLRequest() init. There is no overload for an init() for an optional NSURLRequest which takes the supplied arguments because there isn’t a fallible initializer for an NSURLRequest.

it’s the same as the difference between this

	let x = Int( 123 )

and

	let x = Int( 123 )?

The first works, the second one goes ‘huh?’ because there are no fallible initializers for Int.



_______________________________________________

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: 
 >Simple Swift question (From: Rick Mann <email@hidden>)
 >Re: Simple Swift question (From: Greg Parker <email@hidden>)
 >Re: Simple Swift question (From: Rick Mann <email@hidden>)
 >Re: Simple Swift question (From: Jens Alfke <email@hidden>)
 >Re: Simple Swift question (From: Rick Mann <email@hidden>)
 >Re: Simple Swift question (From: Jens Alfke <email@hidden>)
 >Re: Simple Swift question (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Simple Swift question
  • Next by Date: Re: Simple Swift question
  • Previous by thread: Re: Simple Swift question
  • Next by thread: Simple Swift question
  • Index(es):
    • Date
    • Thread