#IUO NSURLQueryItem.value property should be Optional
| Originator: | danielctull | ||
| Number: | rdar://18236090 | Date Originated: | 04-Sep-2014 11:05 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6, beta 7 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
Swift declares NSURLQueryItem.value as a non-optional string. Query item’s values can be nil for query items without an equals sign. This is stated in the NSURL.h header for the queryItems property of NSURLComponents: “If a query's name-value pair has no equals sign, the query name-value pair string is the name and you get a nil value.”
Steps to Reproduce:
Create a URL with a query without an equals sign and try to access the value as shown in the playground code below:
import UIKit
let URL = NSURL(string: "http://danieltull.co.uk?query")
let components = NSURLComponents(URL:URL, resolvingAgainstBaseURL:false)
for queryItem in components.queryItems as [NSURLQueryItem] {
queryItem.value
}
Expected Results:
Value returns an optional.
Actual Results:
Runtime crash.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!