我有一个解析对象,我保存到LDS,我想通过1个密钥和另一个密钥下的条目来搜索它。
关键:这很好。
checkQuery.whereKeyExists("File-rZVgZNpNuB")
包含的密钥:这不起作用。
checkQuery.whereKey("seachKey", contains: "myItem0000000000")
控制台正在打印:
-[__NSArrayM length]: unrecognized selector sent to instance 0x7c09bbb0
我猜是因为mySearchString是“searchKey”字段中的一个对象,它返回一个NSMutable数组。一旦我有了对象,它很容易从数组中获取数据但我需要在“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
答案 0 :(得分:0)
我相信您收到了该错误,因为"File-rZVgZNpNuB"
是无效密钥。请记住,密钥只能以小写字母开头。