1

Parse documentation says that PFObject -init can't be overriden. Where can i set default values for properties of my PFObject subclass?

user3579086
  • 123
  • 6

1 Answers1

0

On creation of your PFObjects, you can set initial default values for the PFObject subclass. For example:

If you are creating a PFObject that represents an event, and want to initialize it with the Date, then when you first create the PFObject subclass instance, you can set it's "date" key to be [NSDate date] (this gives the current date) with the following line of code

[eventObject setObject:[NSDate date] forKey:@"date"];

Where eventObject is a new instance of your PFObject subclass. You would then want to save your object into Parse, by doing:

[eventObject saveInBackground];
BHendricks
  • 4,423
  • 6
  • 32
  • 59
  • This could definitely be put after every time a new subclassed object is initialized, but it defeats the purpose of having an initializer. OP seems to be asking where you would properly set the defaults within MySubClass.m or something, so that every newly instantiated object has those default values without having to add extra code after the new object is initialized. – Jake T. Oct 17 '16 at 20:39