Methods including NSErrorPointer should return explicit Optional

Originator:robnapier
Number:rdar://17249360 Date Originated:10-Jun-2014
Status:Open Resolved:
Product:Swift SDK Product Version:
Classification: Reproducible:
 
Summary:
In the Swift SDK, ObjC objects are typically converted to implicitly unwrapped Optionals (!). This is usually correct because these almost never take or return nil. But methods that take an NSErrorPointer can almost always return nil, and these methods should return an explicit Optional (?).

Steps to Reproduce:
Consider JSONObjectWithData(options:error:)

Expected Results:
Should return AnyObject?

This would help ensure that the result is unwrapped correctly.

Actual Results:
Returns AnyObject!

This makes using the result very dangerous because it may be nil.

Version:
Swift DP1

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!