iphone - What's the correct way to perform initialization code whether an object is loaded from a nib or created programmatically? -


"itemprop =" text ">

I've noticed that if you want to add a nib you initWithCoder because you want to add the enforcement code, then load the ideas associated with the zodiac Does not get called the named initiator (which means), and if you do not load the view with a nibb, then the same code should be killed in the named starter.

In order to handle both cases, you need the same enforcement code in both methods.

This is the best solution that I have come up with so far but I have to wonder if there is something more conventional than doing so. This code is in a UITableViewCell subclass, but it can actually be any UIView:

  / * * It seems that there must be a standard method for this already. * / - (zero) didFinishInitializingOrUnacrhiving {/ content that makes the most sense to do in an inductor ***} - (id) initWithCoder: (NSCoder *) aDecoder {if (self = [ Super initWithCoder: aDecoder]) {[didfinishInitializingOrUnacrhiving]; } Healthy return; } - (id) initWithStyle: (UITableViewCellStyle) style reuseIdentifier: (NSString *) reuseIdentifier {if (self = [super initWithStyle: genre reuseIdentifier: reuseIdentifier]) {[self-didFinishInitializingOrUnacrhiving]; } Healthy return; }  

So any thoughts on this? To work this "the right way" I'm just completely missing something, are there potential losses here, or am?

I explained it in another answer


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -