1
저는 신속하고 날씨 응용 프로그램을 만드는 데 매우 익숙합니다. 프로토콜이 func weatherManagerFailedToLoadCityWithError(error: ErrorType)
입니다. weatherManager.swift에서이 코드 블록날씨 응용 프로그램의 오류 유형 프로토콜
func weatherManagerFailedToLoadCityWithError(error: ErrorType) {
}
어떤 제안에 weatherController.swift 어떻게해야합니까 일부 위임
} else if status == 404 {
// City not found
if self.delegate != nil {
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.delegate?.weatherManagerFailerToLoadCityWithError(.InvalidResponse)
})
}
} else {
// Some other here?
if self.delegate != nil {
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.delegate?.weatherManagerFailerToLoadCityWithError(.MissingData)
})
}
}
있나요? 다음 함수를 호출
private struct ErrorInformation {
static let Domain = "us.firmaName"
static let ServerNotFoundDomain = "\(ErrorInformation.Domain).notFound"
}
private extension NSError {
static func serverNotFound() -> NSError {
let userInfo = [
NSLocalizedDescriptionKey: NSLocalizedString("Server Not Found", comment: ""),
NSLocalizedFailureReasonErrorKey: NSLocalizedString("The Server you are asking for is not available.", comment: ""),
NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString("Please proof your URL bla-bla-bla.", comment: "")
]
return NSError(domain: ErrorInformation.ServerNotFoundDomain, code: 404, userInfo: userInfo)
}
을 그리고 :