gpt4 book ai didi

Swift - 解析查询 whereKey 包含

转载 作者:行者123 更新时间:2023-11-30 12:38:18 26 4
gpt4 key购买 nike

我有一个解析对象,已保存到 LDS,我想通过 1 个键和另一个键下的条目来搜索它。

关键:这很好。

checkQuery.whereKeyExists("File-rZVgZNpNuB")

包含的 key :这不起作用。

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

最佳答案

我确实相信您收到该错误是因为 "File-rZVgZNpNuB" 是无效 key 。请记住,按键只能以小写字母开头。

关于Swift - 解析查询 whereKey 包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42589092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com