Skip to content

Commit

Permalink
Use initWithCoder: instead of awakeFromNib
Browse files Browse the repository at this point in the history
When configuring an SMPageControl from inside a Storyboard or XIB file, the developer might want to use User Defined Runtime Attributes to configure the instance. awakeFromNib is called after those attributes are evaluated by the loading system, effectively overwriting the attributes defined in the Storyboard or XIB file. Therefore, initWithCoder: is the more appropriate location to perform the initialization.
  • Loading branch information
mbinna committed Feb 8, 2013
1 parent 2835b39 commit 96bafd2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions SMPageControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ - (id)initWithFrame:(CGRect)frame
return self;
}

- (void)awakeFromNib
- (id)initWithCoder:(NSCoder *)aDecoder
{
[super awakeFromNib];
[self _initialize];
self = [super initWithCoder:aDecoder];
if (nil == self) {
return nil;
}

[self _initialize];
return self;
}

- (void)dealloc
Expand Down

0 comments on commit 96bafd2

Please sign in to comment.