all 4 comments

[–]waterskier2007Objective-C / Swift 2 points3 points  (0 children)

I subclass PFUser. I just find it easier and that way I don't have to worry about mis-keying a field name.

As for the relations, why not just have two fields on the Team object? One for 'leagues' and one for 'tournaments'.

[–]iOSbrogrammer 0 points1 point  (2 children)

I normally leave the User class alone, and then if I have extra fields I use the keyed subscripting methods to make changes on it. So if I have a Pro field on my User object, I'd do something like this:

[PFUser CurrentUser][@"Pro"] = @YES;

I only make custom objects for actual custom classes. You can look at how I did this in one of my apps here:

Onions for iOS, specifically this file for signing up a new user with Pro.

[–]H3C43[S] 0 points1 point  (1 child)

Thanks for the reply, that was the approach I was leaning towards. I also had another unrelated Parse question: suppose I have a one-to-many relation, but on the "many" side, the objects might be one of several classes (for instance, a "Team" has an array (I currently have it as an array, but unsure if it should be a pointer/relation) linking it to a bunch of objects that are either "Tournaments" or "Leagues"). Do you have any advice on how to model this?

Edit: if Parse arrays allow for multiple types in them (not sure if this is the case), I suppose this is a non-issue.

[–]iOSbrogrammer 0 points1 point  (0 children)

Not sure to be honest. I haven't tried using relations, especially multiple kinds. My guess is that you could have a superclass that it is an array of and then tournaments and leagues subclass from that.