ios - 获取时如何初始化 PFObject 子类?
<p><p>Parse 文档明确指出,您不应为 PFObject 的子类覆盖 init。这对于在代码中创建的对象没关系,因为您可以覆盖对象方法,就像这样......</p>
<pre><code>@implementaion CustomObject : PFObject <Subclassing>
+ (instancetype) object {
CustomObject *me = ;
// init some instance variables or whatever
return me;
}
@end
</code></pre>
<p>这适用于这种情况:
CustomObject *myThing = ;</p>
<p>但是从查询中获取对象时似乎没有调用对象....</p>
<pre><code>PFQuery *query = ;
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for(int i = 0; i < objects.count; i++){
CustomObject *myThing = objects;
// object method was never called...
}
}
}];
</code></pre>
<p>那么...如何在获取自定义 PFObject 时对其进行初始化?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>可能你还没有注册你的子类。</p>
<p>在</p>之前调用<code></code>
<pre><code>[Parse setApplicationId:@"your id"
clientKey:@"your key"];
</code></pre>
<p>或添加到子类</p>
<pre><code>+ (void) load{
;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 获取时如何初始化 PFObject 子类?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/26913607/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/26913607/
</a>
</p>
页:
[1]