View Full Version : Trouble with Switching views using a Button

Aug 11, 2011, 02:02 PM
I created a project using the View based app every time I add a second view and the code it doesnt seem to work at all.

- (IBAction)switchViews {

MainView *firstView = [[MainView alloc] initWithNibName:@"MainView" bundle:[NSBundle mainBundle]];
[self.view addSubview:firstView.view];
[SecondViewController release];

Thats the code im using and i make the necessary connections but the error i keep getting is "request for member 'view' in something not a structure or union." The error happens on the self.view line.

What could this mean?
Also im using Xcode3.1.3 if that makes a difference.

Aug 11, 2011, 03:12 PM
Well, your error code is giving you kind of a hand on.
your self, doesn't have a view property, what is your "self", how do we know what your "self" is ;)
Because your code is correct. Just, I think you are thinking wrong in your flow.