I have a class that I\'m deriving from UIView, and I wanted to create a -init class for it like so:
- (id) init
{
if (self = [super init]) {
// m
There are two designated initializers for UIViewController
and UIView
they are initWithCoder
called from nib
, and initWithFrame
called from code. Init
is not the designated initializer for those objects.
If you want to cover both bases you can do something like this:
-(void)initializationCodeMethod{
<#Initialization Code Here#>
}
-(id)initWithFrame:(CGRect)frame{
if ((self = [super initWithFrame:frame])){
[self initializationCodeMethod];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder{
if ((self = [super initWithCoder:aDecoder])){
[self initializationCodeMethod];
}
return self;
}