I've got an NSObject Ive set up controlling a couple of NSWindows. One of these NSWindows contains a custom NSView. I need to tell the NSView to run a method however the view will not do this. Xcode 2.5 tells me that the object may not respond to the method that I have called for, here is the code:
MenuController.m
#import "MenuController.h"
int gameOn = 0; //variable for if the game is running ATM
@implementation MenuController
-(void)playIt{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSThread detachNewThreadSelector:@selector (callGameView) toTarget:self withObject:nil]; //make a new thread for the game window
if (gameOn == 0){
[menuWindow orderOut:self];
[NSApp activateIgnoringOtherApps:YES]; //set up the game window as the visable window, set focus on it
gameOn = 1;
[gameWindow makeFirstResponder: MainView];
[gameWindow makeKeyAndOrderFront:self];
}
while(gameOn != 0){ //initiate the game loop
//the game loop
[self callGameView];
}
[pool release];
}
-(void)callGameView{ //call for the game loops primary interactions with the game view
[MainView gameLoop];
}
MenuController.h
#import <Cocoa/Cocoa.h>
#import "GameView.h"
@interface MenuController : NSObject {
IBOutlet id menuWindow; //outlet for this window (show hide, ect)
IBOutlet id gameWindow; //the games window
IBOutlet GameView *MainView; //the game view
}
GameView.m
-(void)gameLoop{
NSLog(@"Its ALIVE!");
}