我的类有一个 PFUser 指针数组。
我正在尝试检查 PFUser.current () 是否在指针数组中。
这是我的代码片段。
class News: PFObject, PFSubclassing {
@NSManaged var notiBy: PFUser?
@NSManaged var notiTo: PFUser?
//[News]()
// @NSManaged var notiArray: [PFUser]?
@NSManaged var notiArray: Array<String>
var newsLiveQuery: PFQuery<News> {
return News.query()?
.whereKeyExists("objectId")
.includeKeys(["notiBy", "postObj", "notiTo", "notiArray"])
.whereKey("notiArray", equalTo: PFUser.current()!)
.order(byDescending: "createdAt")
as! PFQuery<News>
}
但是我收到了一条 JSON 错误消息。
但是我可以像这样得到 PFObject 的结果
[<News: 0x1740b5480, objectId: zyCEHc78l6, localId: (null)> {
checked = 0;
messageText = Hellow;
notiArray = (
"<PFUser: 0x1742ee800, objectId: a85SoYwEiE, localId: (null)>"
);
notiBy = "<PFUser: 0x1742ed100, objectId: tmWHuptLmd, localId: (null)>";
notiTo = "<PFUser: 0x1742ede00, objectId: a85SoYwEiE, localId: (null)>";
postObj = "<Post: 0x1742ee700, objectId: CXaSlvrW4G, localId: (null)>";
type = comment;
}]
看看那个
我认为它应该可以工作,但是...为什么我无法运行查询?
有人知道吗?
最佳答案
我相信您不会以字符串形式返回用户名。尝试使用 PFUser.current()!.username 代替
关于swift - 如何检查Parse子类中PFUser的指针数组中是否存在特定用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41244573/