• 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: Help with Swift changes to optionals
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with Swift changes to optionals


  • Subject: Re: Help with Swift changes to optionals
  • From: Rick Mann <email@hidden>
  • Date: Wed, 15 Apr 2015 13:22:09 -0700

> On Apr 15, 2015, at 12:47 , Marco S Hyman <email@hidden> wrote:
>
>
>> On Apr 15, 2015, at 12:29 PM, Rick Mann <email@hidden> wrote:
>>
>> I used to have this code prior to 1.2, which compiled and ran fine, but now I get an error on the last line:
>>
>> '?' must be followed by a call, member lookup, or subscript
>
> …
>
>>
>>   var query : String?;
>
>>
>>   log("query: '\(query?)'”);
>
> Use
>
>   log("query: '\(query)'”);
>
> If query is nil the result will be “query: ‘nil’” because string interpolation
> works with optionals.

I stand corrected; that *does* work. I think I fell victim to Xcode showing me an error because although it worked in the current target, I had not yet rebuilt another target, so it was still showing the error (I REALLY hate Xcode's error reporting).

Thanks!

--
Rick Mann
email@hidden



_______________________________________________

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: 
 >Help with Swift changes to optionals (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: layout method not getting called on Content View
  • Next by Date: First responder (?) problem, and orphaned highlight boxes
  • Previous by thread: Help with Swift changes to optionals
  • Next by thread: First responder (?) problem, and orphaned highlight boxes
  • Index(es):
    • Date
    • Thread