Parse - Using relations versus pointers?

前端 未结 4 532
生来不讨喜
生来不讨喜 2020-12-28 09:49

I am using Parse as my backend. I have problems setting up the correct relation between objects.

I basically have a class named Post, each post belongs to a user(PFU

4条回答
  •  时光说笑
    2020-12-28 10:44

    Create A PFSubClass like

    yourClassName:PFObject with PFSubclassing 
    

    and then in the header file create a Pointer relation

    @property(nonatomic, strong) PFUser *userLikeRelation; 
    

    add in m file add

    + (NSString *)parseClassName {
    
        return @"parseTableName";
    
    }
    
    + (void)load {
    
        [self registerSubclass];
    
    } 
    

    finally in the View Controller set relation in query when you are save data in parse.

    yourClassName *yourClassNameObj = [yourClassName objectWithClassName:[yourClassName parseClassName]];
    
    [yourClassName setUserCommentRelation:[PFUser currentUser]];
    

    for fetching data you can get data with include key

    [yourClassNameObj includeKey:@"NameofRelation"];
    

提交回复
热议问题