I created a nib in the Interface Builder with a sub view that I will use for loading dynamic content. The subview is wired to an IBOutlet and when a certain event occurs I went to load a specific control into that sub view. I tried instantiating the view I was going to use and then adding it as a subview of the the contentView IBOutlet, but all I get is an exception.
My application crashes on that last line. (Which also happens to be producing a "warning: passing argument 1 of 'addSubview:' from distinct Objective-C type.". I tried casting it to a (UIView *) but that still gives me exceptions.
Exception:
2008-11-06 23:28:34.580 iPhoneHelloWorld[4069:20b] *** -[SellViewController superview]: unrecognized selector sent to instance 0x479480
2008-11-06 23:28:34.582 iPhoneHelloWorld[4069:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[SellViewController superview]: unrecognized selector sent to instance 0x479480'
Code:
- (IBAction)sellItem {
if(sellView == nil) {
SellViewController *viewController = [[SellViewController alloc] initWithNibName:@"SellViewController" bundle:[NSBundle mainBundle]];
self.sellView = viewController;
[viewController release];
}
[self.sellView setItem:item];
[self.contentView addSubview:self.sellView];
}
My application crashes on that last line. (Which also happens to be producing a "warning: passing argument 1 of 'addSubview:' from distinct Objective-C type.". I tried casting it to a (UIView *) but that still gives me exceptions.
Exception:
2008-11-06 23:28:34.580 iPhoneHelloWorld[4069:20b] *** -[SellViewController superview]: unrecognized selector sent to instance 0x479480
2008-11-06 23:28:34.582 iPhoneHelloWorld[4069:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[SellViewController superview]: unrecognized selector sent to instance 0x479480'