tags:

views:

13

answers:

1
#import "gameOver.h"
#import "MainMenu.h"

@implementation gameOver
@synthesize paButton;

-(IBAction) playAgain
{
 playagain = [[game alloc] initWithNibName: @"game" bundle: [NSBundle mainBundle]];

 [[self view] addSubview: [playagain view]];
}

-(IBAction) goBack
{
    MainMenu = [[back alloc] initWithNibName: @"back" bundle: [NSBundle mainBundle]];

 [[self view] addSubview: [MainMenu view]];
}
A: 
#import "MainMenu.h"

From this, I infer that MainMenu is a class.

MainMenu = [[back alloc] initWithNibName: @"back" bundle: [NSBundle mainBundle]];

You can't do that. You can only assign to a variable, or a member of a structure stored (at some level) in a variable; you cannot assign to a class.

These look like view controllers. Is this Cocoa or Cocoa Touch? If it's Cocoa Touch, I'm pretty sure you would be better off to let the view controllers manage the view stack for you, rather than trying to munge the view hierarchy yourself. (In particular, adding each controller's view to your view will only work once until you take the view back out of your view.)

Peter Hosey