解析本地数据存储和PFObject子类 [英] Parse local datastore and PFObject subclasses

查看:62
本文介绍了解析本地数据存储和PFObject子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当我在iOS中引入Parse本地数据存储并快速使用它添加了几个功能时,我感到非常高兴.在一个地方,我使用

So I was delighted when Parse local data store got introduced in iOS and quickly added couple of functionalities using it. In one place i persist certain collection of objects using

[Spot pin] 

FYI Spot是PFObject的子类. 现在,我打开另一个屏幕,我刚刚保留的那个对象是PFQuery结果的一部分,但是我不断遇到异常:

FYI Spot is a subclass of PFObject. Now, i open up another screen where that object that i just persisted is part of the PFQuery result, however i keep getting exception:

[PFObject名称]:无法识别的选择器已发送到实例0x7fd2716422e0

[PFObject name]: unrecognized selector sent to instance 0x7fd2716422e0

在这种情况下,像Parse一样,将固定对象作为其文档状态:

Looks like Parse in this case is referencing the pinned object as their doc states:

启用后,任何给定PFObject都只有一个实例. 例如,假设您有一个"GameScore"类的实例 使用"xWMyZ4YEGZ"的objectId,然后对所有对象发出PFQuery 具有该objectId的"GameScore"实例.结果将是 您已经在内存中的对象的相同实例.

When enabled, there will only be one instance of any given PFObject. For example, imagine you have an instance of the "GameScore" class with an objectId of "xWMyZ4YEGZ", and then you issue a PFQuery for all instances of "GameScore" with that objectId. The result will be the same instance of the object you already have in memory.

但不是我的子类,而是以为它只是一个PFObject ...有什么方法可以处理它?<​​/p>

but rather than my subclass it's thinking it's just a PFObject... is there any way to deal with it?

推荐答案

我自己想出了一个.事实证明,您必须在子类之前上调用registerSubclass方法,甚至使用其AppId和clientKey初始化Parse并启用localDataStore.因此,代码应如下所示:

Figured this one out myself. Turns out you have to call registerSubclass method on the subclasses BEFORE you even initialize Parse with it's AppId and clientKey and enable localDataStore. So the code should look:

[Spot registerSubclass];
[Parse setApplicationId:@"XXX" clientKey:@"XXX"];
[Parse enableLocalDatastore];

这篇关于解析本地数据存储和PFObject子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆