Skip to content

Instantly share code, notes, and snippets.

@tapi
Created March 27, 2015 18:31
Show Gist options
  • Save tapi/2d1479851b4b75eaf055 to your computer and use it in GitHub Desktop.
Save tapi/2d1479851b4b75eaf055 to your computer and use it in GitHub Desktop.
Wouldn't this work instead of a nil default?
extension NSError{
//...
class func
myParseError(description:String?="Parse failed.") -> NSError {
let info = [NSLocalizedDescriptionKey: description]
return self(
domain:myDomain,
code:MyErrorCodes.ParseError.rawValue,
userInfo:info)
}
}
// Original from http://www.figure.ink/blog/2015/3/21/clean-optional-parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment