我在一个Swift项目中使用AFNetworking。
1-Typealias闭包:
typealias successBlock = (AFHTTPRequestOperation! ,AnyObject!)-> Void
typealias failureBlock = (AFHTTPRequestOperation, NSError!) -> Void
2-定义功能:
func getUserInfo(success: (successBlock)!, failure: (failureBlock)!) {
let path = "https://api.wei.s.json"
let parameters = ["source":"key"]
self.GET(path, parameters: parameters, success: success, failure: failure)
}
3-错误:
谢谢你的帮助。
EIDT:
typealias failureBlock = (AFHTTPRequestOperation, NSError!) -> Void
至
typealias failureBlock = (AFHTTPRequestOperation!, NSError!) -> Void
最佳答案
我觉得你想念一个!在failureBlock类型别名定义上,它期望显式展开的可选AFHTTPRequestOperation而不是标准的AFHTTPRequestOperation,它们实际上是不同的类型。我相信应该
typealias failureBlock = (AFHTTPRequestOperation!, NSError!) -> Void