写了个函数,带函数的参数的:
func getUrlRespJsonDict_async(url:String, respJsonDictHandler:((JSON?) -> Void)) { var decodedJsonDict:JSON? let params:Dictionary<String, AnyObject>? = nil do { let opt = try HTTP.GET( url, parameters: params, requestSerializer: JSONParameterSerializer()) opt.start { response in if let err = response.error { print("error: \(err.localizedDescription)") return } print("response.statusCode=\(response.statusCode)") print("opt finished: \(response.description)") decodedJsonDict = JSON(data: response.data) print("decodedJsonDict=\(decodedJsonDict)") respJsonDictHandler(decodedJsonDict) } } catch let httpGetError { NSLog("http get url=\(url) with params=\(params) got error= \(httpGetError)") } }
但是之前去调用却不行
但是现在调用又好了:
可以编译通过了:
func fetchTeamItemList_async() { 。。。 getUrlRespJsonDict_async(fullFetchTeamIdListUrl, respJsonDictHandler: teamItemJsonDictHandler) } func teamItemJsonDictHandler(respJsonDict:JSON?) { 。。。 }