[英]Can't get pin object from local parse database
I am using parse for my iOS app and it works fine. 我正在为我的iOS应用程序使用parse,它工作正常。
I wanted to implement offline feature so I am using pinInBackground
to save PFObject
to local database. 我想实现离线功能,因此我正在使用
pinInBackground
将PFObject
保存到本地数据库。 But I can't retrieve it. 但是我找不到它。
For my special reason, I've generated unique UUID
for every PFObject
pin name and used it. 由于特殊原因,我为每个
PFObject
引脚名称生成了唯一的UUID
并使用了它。
{
...
NSString *uuid = [[NSUUID UUID] UUIDString];
[CustomObject pinInBackgroundWithName:uuID];
...
}
It returns success but I can't retrieve it. 它返回成功,但我无法检索到它。
Following is the query code to get pin Object
. 以下是获取pin
Object
的查询代码。
{
...
PFQuery *query = [CustomObject query];
[query fromLocalDatastore];
[query fromPinWithName:uuID];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
{
if(!error)
block(objects, nil);
else
block(nil, error);
}];
...
}
But objects has 0 elements always. 但是对象始终具有0个元素。
Any help would be greatly appreciated. 任何帮助将不胜感激。
Thanks 谢谢
Update: 更新:
This is the Pin object saved in parse local database. 这是保存在解析本地数据库中的Pin对象。
{"isDeletingEventually":0,"className":"_Pin","__complete":true,"__operations":[{"_name":"16F31F2C-6375-4107-A0B6-FDCBA9810847","__updatedAt":{"__type":"Date","iso":"2017-07-02T18:33:02.825Z"},"_objects":[{"__type":"OfflineObject","uuid":"FF3D069C-864F-4D87-9511-F2738A5F95F4"}],"__uuid":"71BAF309-58D4-4BCC-82D8-BB35C25F1632"}]}
The problem was the query for local database. 问题是查询本地数据库。
I've changed the query like this and it worked for me. 我已经改变了这样的查询,它为我工作。
{ {
...
PFQuery *query = [[[CustomObject query] fromLocalDatastore]ignoreACLs];
[query fromLocalDatastore];
[query fromPinWithName:uuID];
...
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.