When I make an object to use in NIB, the object should implement -initWithCoder:
. However I can't figure out regular pattern implementing this.
I have been used this code.
- (id) initWithCoder:(NSCoder *)aDecoder
{
if(self=[super initWithCoder:aDecoder])
{
// initialize my object.
}
return self;
}
But I have to make same code for UIView instantiated by code like this.
- (id) initWithCoder:(NSCoder *)aDecoder
{
if(self=[super initWithCoder:aDecoder])
{
// initialize my object.
}
return self;
}
- (id) initWithFrame:(CGRect)frame
{
if(self=[super initWithFrame:frame])
{
// initialie my obejct.
}
return self;
}
I feels something wrong. Any recommendations?
*Of source the initialization logic can be extracted into a new method, but it's not a point.