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

Help with Swift changes to optionals


  • Subject: Help with Swift changes to optionals
  • From: Rick Mann <email@hidden>
  • Date: Wed, 15 Apr 2015 12:29:03 -0700

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

func
httpResponseForMethod(inMethod: String!, URI inPath: String!)
    -> NSObject!
{
    ...

    var query : String?;
    if let r = inPath.rangeOfString("?")
    {
        requestRoot = inPath.substringToIndex(r.startIndex);
        query = inPath.substringFromIndex(r.endIndex);
    }
    else
    {
        requestRoot = inPath;
    }

    ...

    log("query: '\(query?)'");
                        ^ <------------ ERROR HERE
}

I tried removing the '?', but I get the same error. Do I have to wrap the whole thing in a "let" expression?

I really do prefer Objective-C's handling of messages passed to nil.

--
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


  • Prev by Date: layout method not getting called on Content View
  • Next by Date: layout method not getting called on Content View
  • Previous by thread: Re: layout method not getting called on Content View
  • Next by thread: Re: Help with Swift changes to optionals
  • Index(es):
    • Date
    • Thread