Reputation: 21903
I have a class with a large number of init...
methods (UITableViewCell). My extension has an extra property which when set, will adjust various cell properties such as colours. I had two options for handling the change to the property.
Item #1 seems to be the simplest to apply, but means I have to deal with manually putting in the setter code (retains involved) as per Apples guidelines.
Item #2 sounds nice initially because I don't have to add the setter boiler place, but would cost more code because I would have to override all the inits.
Is there any other alternatives?
Upvotes: 0
Views: 361
Reputation: 185861
You only have to override the designated initializer(s). Typically, most classes only have one designated initializer, and classes which conform to <NSCoding>
have two (the second being -initWithCoder:
).
Don't forget, if you set up KVO in init, you'll have to remember to unregister it in -dealloc
. Objects don't automatically unregister KVO when they go away, and if you forget then whatever object that gets allocated at the same address in the future will inherit the leaked KVO observers.
Upvotes: 2