class AlamofireService {
static let alamofireService = AlamofireService()
private init() {
}
internal func makePostServiceRequest(url: String, parameters: AnyObject, completion: (inner:() throws -> NSDictionary) -> Void) -> Void{
Alamofire.request(.POST, URL_BASE, parameters: [IOS_PARAMS : parameters], encoding:.JSON).validate()
.responseJSON
{
response in switch response.result
{
case .Success(let JSON):
print("Success with JSON: \(JSON)")
let response = JSON as! NSDictionary
print(response)
completion(inner: { return response })
case .Failure(let error):
print("Request failed with error: \(error)")
completion(inner: { throw error })
}
}
}
internal func makeGetServiceRequestTemplates(completion: (inner:() throws -> NSDictionary) -> Void) ->Void {
Alamofire.request(.GET, URl_TEMPLATES).validate().responseJSON
{
response in switch response.result
{
case .Success(let JSON):
print("Success with JSON: \(JSON)")
if let array = JSON as? [Dictionary<String, AnyObject>] {
for var i=0; i < array.count; i++ {
let templates = Mapper<VQuizTemplateTo>().map(array[i])
print(templates)
}
}
completion(inner: { return response }) //error is on this line
case .Failure(let error):
print("Request failed with error: \(error)")
completion(inner: { throw error })
}
}
}
兩個相同的方法的值,用於第一沒有錯誤,並用於第二是在地方,因爲我標記。無法弄清楚什麼是錯誤的,尤其是對於這種無意義的錯誤。 你能告訴我我在做什麼這樣的錯誤嗎?無法將類型「響應<AnyObject,NSError>」到閉合結果類型「的NSDictionary」
更換
completion(inner: { return response })
什麼你得到的錯誤? – renjithr