我子類的PFObject下面的類(動態性能和+負載& parseClassName方法在.m文件)PFUser財產上的子類PFObject
@interface DAOpponents : PFObject <PFSubclassing>
@property (nonatomic, strong) PFObject* fromUser;
@property (nonatomic, strong) PFObject* toUser;
@property (nonatomic) BOOL isVisible;
@property (nonatomic) BOOL isPersistent;
+ (NSString *)parseClassName;
@end
在單元測試我嘗試創建一個樣DAOpponents-對象:
DAOpponents* follow = [DAOpponents object];
follow.fromUser = user1; // caught "NSInvalidArgumentException", "PFObject values may not have class: PFUser"
follow.toUser = user2;
[follow save];
如果我做同樣沒有對手的一個子類的版本有沒有異常
PFObject* follow = [[PFObject alloc] initWithClassName:@"DAOpponents"];
[follow setObject:user1 forKey:@"fromUser"]; // no exception!!!
[follow setObject:user1 forKey:@"toUser"];
爲什麼子類PFObject不能指向PFUser對象?
任何幫助表示讚賞!非常感謝!
你試過聲明FROMUSER和TOUSER爲'PFUser *''不* PFObject'? – Paulw11 2014-10-11 19:40:45
@ Paulw11是的,我甚至試圖手動覆蓋setter/getter(沒有動態生成)和一個強制轉換「(PFObject *)user1;」太。 – cakl 2014-10-11 19:43:36