gpt4 book ai didi

ios - 是否可以使用 PFUser 的两个子类?

转载 作者:行者123 更新时间:2023-11-29 12:27:23 26 4
gpt4 key购买 nike

我在我的应用程序中使用 parse.com iOS 框架。我的 User 对象是标准解析 PFUser 的子类。我的应用程序中有两种截然不同的用户:学生和教师。我厌倦了遍布我的代码的大量 if (user.isTeacher) {...} else {...} 语句,它看起来像是多态性的完美目标。问题是:解析框架如何判断它是否应该在我的查询中返回 TeacherStudent 子类 PFUser ?实际上有什么方法可以让 PFUser 的两个子类解析?还有其他想法吗?

最佳答案

不可能,至少对于当前版本的 Parse SDK (1.7.1),因为第二个子类的 registerSubclass 方法崩溃并显示消息:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to register both AnotherUser and User as the native PFObject subclass of _User. Cannot determine the right class to use because neither inherits from the other.'

关于ios - 是否可以使用 PFUser 的两个子类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28652599/

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