我对这一切真的很陌生,我试图从API(https://qodyhvpf8b.execute-api.us-east-1.amazonaws.com/test/books)中获取一些数据,并使用ViewController的结构询问Service,Service到DAO以及其他方法,但是在DAO代码中,出现以下消息:无法将类型为'Book'的值转换为预期的参数类型'[String:AnyObject]'在代码下方:
//DAO Code
class FluxApiDao {
func getBookFromAPI(completion: @escaping ([Book]) -> Void) {
Alamofire.request("https://qodyhvpf8b.execute-api.us-east-1.amazonaws.com/test/books").responseJSON { (response) in
if let forBooksInRootArray = response.value as? [ [String:AnyObject] ]{
var booksArray: [Book] = []
for oneDict in booksArray {
var newBook: Book = Book(dictionary: oneDict)
booksArray.append(newBook)
}
completion(booksArray)
}
}
}
}