2
更新到Xcode8和Alamofire4之後我在代碼「Response < [T]」上得到錯誤'使用未聲明的類型響應',(它使用ObjectMapper和realm )xcode8 Alamofire 4更新錯誤「使用未聲明的類型響應」
class FetchData {
static func get <T: Object> (_ type: T.Type, success:@escaping() -> Void, fail:@escaping (_ error:NSError)->Void)->Void where T:Mappable, T:Meta {
Alamofire.request(type.url(), method: .get)
.responseArray { (response: Response<[T], NSError>) in
//.responseArray { (response: DataResponse<[T], NSError>) in
switch response.result {
case .success(let items):
autoreleasepool {
do {
let realm = try Realm()
try realm.write {
for item in items {
realm.add(item, update: true)
}
}
} catch let error as NSError {
fail(error: error)
}
}
success()
case .failure(let error):
fail(error: error)
}
}
}
}
我有代碼工作,根據本指南使用Object Mapper將數據映射到領域; https://blog.hyphe.me/realm-and-alamofire-in-a-effective-harmony/
將其更改爲DataResponse不起作用。 任何想法?