Skip to content

Commit

Permalink
Added methods to allow loading subclass of LeavesViewController from …
Browse files Browse the repository at this point in the history
…a NIB
  • Loading branch information
Robert Simpson authored and Robert Simpson committed Jul 23, 2010
1 parent 0315bbb commit f860ed4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Leaves/LeavesViewController.h
Expand Up @@ -13,5 +13,10 @@
LeavesView *leavesView;
}

// added by Lnkd.com?24 - use designated initializer to avoid continuous loop when loaded from NIB
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle;

- (id)init;

@end

24 changes: 20 additions & 4 deletions Leaves/LeavesViewController.m
Expand Up @@ -10,11 +10,27 @@

@implementation LeavesViewController

- (void) initialize {
leavesView = [[LeavesView alloc] initWithFrame:CGRectZero];
}

// changed by Lnkd.com?24 - use designated initializer to avoid continuous loop when loaded from NIB
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
{
if (self = [super initWithNibName:nibName bundle:nibBundle]) {
[self initialize];
}
return self;
}

- (id)init {
if (self = [super init]) {
leavesView = [[LeavesView alloc] initWithFrame:CGRectZero];
}
return self;
return [self initWithNibName:nil bundle:nil];
}

// added by Lnkd.com?24 - allow loading LeavesViewController subclass from a NIB
- (void) awakeFromNib {
[super awakeFromNib];
[self initialize];
}

- (void)dealloc {
Expand Down

0 comments on commit f860ed4

Please sign in to comment.