0

我已经设置了一个 NSObject 来控制几个 NSWindows。其中一个 NSWindows 包含一个自定义 NSView。我需要告诉 NSView 运行一个方法,但是视图不会这样做。Xcode 2.5 告诉我该对象可能不会响应我调用的方法,这里是代码:

菜单控制器.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];
}

菜单控制器.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


}

游戏视图.m

-(void)gameLoop{
    NSLog(@"Its ALIVE!");
}
4

0 回答 0