Help with Swift changes to optionals
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