我有一个NSObject Ive设置控制几个NSWindows。其中一个NSWindows包含一个自定义NSView。我需要告诉NSView运行一个方法,但视图不会这样做。 Xcode 2.5告诉我对象可能没有响应我要求的方法,这里是代码:
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!");
}