1

Why does adding a subview in the awakeFromNib method cause it to go into a infinate loop? Where should subviews be added? thanks.

- (void)awakeFromNib
{
     outlineViewController = [[OutlineViewController alloc] initWithNibName:nil bundle:nil];

     NSArray *subViews = [leftView subviews];
     if ([subViews count] > 0)
     {
         [[subViews objectAtIndex:0] removeFromSuperview];
     }

     [leftView addSubview:outlineViewController.view];

}

mfc
  • 3,018
  • 5
  • 31
  • 43

1 Answers1

0

Maybe it is due to

     outlineViewController = [[OutlineViewController alloc] initWithNibName:nil bundle:nil];

which calls initFromCoder which calls then awakeFromNib. if OutlineViewController is the same object who's awakeFromNib you posted it is so.

Stan
  • 6,511
  • 8
  • 55
  • 87