10. enum StringKey {
case AccessibilityHomeConfirmButton
case DialogInsufficientFundsTitle
...
}
func localized(value: Strings) -> String {
switch value {
case .AccessibilityHomeConfirmButton:
return String.localized(“Accessibility.Home.Confirm.Button”)
...
}
}
Static resources
11. extension HTTP {
enum Error: ErrorType {
case InvalidResponse(request: NSURLRequest, response: NSURLResponse?)
case TransportError(request: NSURLRequest, error: NSError)
case HTTPError(request: NSURLRequest, response: NSHTTPURLResponse, responseData: NSData?)
case CannotCreateURL(components: NSURLComponents)
case InvalidURL(urlString: String)
case AuthServiceFailure
case CannotBindStreamPair(request: NSURLRequest)
case StreamWriting(request: NSURLRequest, error: NSError?)
case StreamGzipEncoding(request: NSURLRequest, operation: HTTP.Error.GzipOperation)
}
}
Strong ErrorType
12. extension JSON.Error {
struct Encode: ErrorType {
public let error: NSError
public let source: Any
}
enum Decode: ErrorType {
case Unexpected
case Serialization(error: NSError, data: NSData)
case SchemeMismatch(error: JSON.Error.SchemeMismatch, body: AnyObject?)
}
struct SchemeMismatch: ErrorType {
public let pathComponents: [String]
public let reason: String
}
}
Strong ErrorType
13. public enum JSONTaskError: ErrorType {
case Task(error: HTTP.Error)
case Request(error: JSON.Error.Encode)
case Response(response: HTTP.Response, error: JSON.Error.Decode)
}
Strong ErrorType