0
我有一個解析對象,我已經保存到LDS,我想通過1鍵和另一個鍵下的條目進行搜索。Swift - 解析查詢whereKey包含
關鍵:這很好。
checkQuery.whereKeyExists("File-rZVgZNpNuB")
包含的鍵:這不起作用。
checkQuery.whereKey("seachKey", contains: "myItem0000000000")
該控制檯是打印:
-[__NSArrayM length]: unrecognized selector sent to instance 0x7c09bbb0
我猜因爲mySearchString是它返回一個NSMutable陣列的「searchKey」字段內的對象。它很容易從數組中獲取數據,一旦我有對象,但我需要在「searchKey」字段中搜索此字符串以查找對象。由於各種原因,我不能用「myItem0000000000」鍵來保存對象。也許我可以添加它作爲第三個關鍵,當我保存對象,但似乎有點混亂。
它在那裏,如果我通過SQL Lite查看對象,我可以看到它。
{"className":"downloadedAudio","__complete":true,"__operations":[{"ACL":{"*":{"read":true},"rZVgZNpNuB":{"write":true,"read":true}},"File-rZVgZNpNuB":{"__op":"Add","objects":[{"url":"https:\/\/parse-server-nextbreath-s3-bucket.s3.amazonaws.com\/b5d2110dce0b50dc3a1c620731fad66e_The%20Name%20of%20the%20Wind%2024-92.mp3","name":"b5d2110dce0b50dc3a1c620731fad66e_The Name of the Wind 24-92.mp3","__type":"File"}]},"__uuid":"77AE38AF-1ADB-4795-9BB0-5A5AB7205E28","__updatedAt":{"iso":"2017-03-03T21:28:19.637Z","__type":"Date"},"searchKey":{"__op":"Add","objects":["myItem0000000000"]}}],"isDeletingEventually":0}
---- ----編輯搜索 :
let searchKey = "File-\(PFUser.current()!.objectId!)"
let checkQuery = PFQuery(className: "downloadedAudio")
checkQuery.whereKeyExists(searchKey)
//checkQuery.whereKeyExists(item.name)
//checkQuery.whereKey("seachKey", contains: item.name)
checkQuery.fromLocalDatastore()
checkQuery.getFirstObjectInBackground(block: { (object, error) in
if object != nil {
// object?.unpinInBackground()
object?.unpinInBackground(block: { (success, error) in
if success {
節省:
let query = PFQuery(className: "Part")
query.whereKey("objectId", equalTo: selectedObjectId)
query.getFirstObjectInBackground { (object, error) in
if error != nil || object == nil {
// ----
} else {
let searchKey = "File-\(PFUser.current()!.objectId!)"
downloadedAudio.add(object?.object(forKey: "partAudio") as! PFFile, forKey: file)
downloadedAudio.add(object?.object(forKey: "partName") as! String, forKey: searchKey)
let downloadedFile = object?.object(forKey: "partAudio") as! PFFile
downloadedFile.getDataInBackground({ (data, error) in
searchKey字段是否爲解析服務器中的數組類型?你的最後一行有一些額外的東西...共享你的整個快速解析下載代碼,它打印什麼錯誤...在我的項目中,它的工作很棒... –