I\'m making an app, and I have a class with quite a lot properties and I was wondering if it was possible to give them a default value. Because if I make an init method, it\'s a
For such a large number of attributes like that, I'd be inclined to store the data as a dictionary rather than individual properties, and I would store the defaults in a property list. NSDictionary
objects can be initialised with a property list easily.
If using a dictionary is not to your tastes, I'd still store the defaults in a property list, and in the designated initialiser, I would loop over the items in the property list and apply them to self
using key-value coding. You should note that this is only appropriate for trusted data, not user-supplied data, as it could otherwise be hijacked to set other properties that you aren't expecting.