-1
這是失敗的行,錯誤消息爲「無法將類型[AnyObject]的值轉換爲期望的參數類型[ PFObject]」無法將[AnyObject]類型的值轉換爲期望的參數類型[PFObject] - 解析&Swift II錯誤
self.customObtainAllHandlerWithObjects(對象,成功:成功,失敗:失敗)
進口的UIKit 進口解析
類AbstractService:BaseService {
private let _cache = AbstractCache<T>()
private let _parser = AbstractParser<T>()
/// Store all completionHandlers for convertFromParseObject operations here. Need this to avoid a concurrent conversions of the same object.
var conversions = Dictionary<String, [(entity: T) -> Void]>()
/// Contains ids of objects, which need their videos to be downloaded.
var queue: [(entityId: String, file: PFFile)] = []
var isQueueDownloading = false
var className: String {
get {
fatalError("This property must be overridden")
}
}
// MARK: - Create
func createEntity() -> T {
let entity = T()
cache().appendEntity(entity)
return entity
}
// MARK: - Obtain all
/// Base method, which obtains entities from Parse database.
///
/// - parameter skip: Number of records, which will be skipped.
/// - parameter limit: Max number of entities returned.
/// - parameter constraints: A block, which applies constraints to PFQuery. E.g. query.includeKey("author") or query.whereKey("user", equalTo: PFUser.currentUser()).
/// - parameter success: Success block. Executes when operation successfully finished.
/// - parameter failure: Failure block. Executes when operation fails.
func obtain(skip skip: Int?, limit: Int?, constraints applyConstraints: ((query: PFQuery) -> PFQuery)?, success: (entities: [T]) -> Void, failure: FailureCompletionHandler) {
var query = PFQuery(className: className)
if let skip = skip {
query.skip = skip
}
query.limit = limit ?? 1000
if let applyConstraints = applyConstraints {
query = applyConstraints(query: query)
}
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if let error = error {
self.callFailureCompletionHandler(failure, error: error)
}
else {
if let objects = objects {
self.customObtainAllHandlerWithObjects(objects, success: success, failure: failure)
}
else {
failure(allowRetry: false, errorMessage: "Cannot load \(self.className)")
}
}
}
}
請不要用截圖來展示您的代碼:If一個想驗證它,好心靈將不得不重新鍵入它。此外,它很難閱讀。請添加[最小,完整和可驗證的示例](http://www.stackoverflow.com/help/mcve)。您可能想閱讀[我如何提出一個好問題](http://stackoverflow.com/help/how-to-ask),這會增加獲得有用答案的可能性_drastically_。 –
行動,對不起。通過入門指南應該做得更好。試圖找出解決辦法並尋找快速解決方案非常沮喪。 –