Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jeremy1026

macrumors 68020
Original poster
Nov 3, 2007
2,215
1,029
MainView.h

Code:
#import "GameView.h"

@interface MainScreen : NSView {
	
	GameView *gmView;
	
}

MainView.m

Code:
[gmView change];

GameView.m

Code:
- (void) change { Lala


What am I doing wrong. 'change' in GameView won't fire.

I also tried plopping
Code:
GameView *gmView = (GameView *)[NSApplication sharedApplication];

into MainView.m, and removing the line from MainView.h, same result, nothing happened.
 

Jeremy1026

macrumors 68020
Original poster
Nov 3, 2007
2,215
1,029
Do you have change declared in your GameView.h?
Code:
@interface GameView : ??? {
}
- (void) change;
@end

Yes, I do, sorry, forgot my .h.

Code:
#import <Cocoa/Cocoa.h>

@interface GameView : NSView {

	
	
}

- (void) change;

What's weird is, there are no errors or warnings.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
What evidence do you have that the line:
Code:
[gmView change];
is being run at all?

What evidence do you have that the method change is not being called?

Have you put some debug in change and around the line that is passing that message to gmView? Have you ensured that gmView is not nil before the message change is passed to it?

-Lee
 

Jeremy1026

macrumors 68020
Original poster
Nov 3, 2007
2,215
1,029
What evidence do you have that the line:
Code:
[gmView change];
is being run at all?

What evidence do you have that the method change is not being called?

Have you put some debug in change and around the line that is passing that message to gmView? Have you ensured that gmView is not nil before the message change is passed to it?

-Lee

Ok, I changed to
Code:
if (gmView != nil) { [gmView change]; }
and added an NSLog in there, and nothing is being logged. So it looks like gmView is being considered nil. So I must be missing something in the declaration.
 

BorgCopyeditor

macrumors newbie
Jan 7, 2009
14
0
Ok, I changed to
Code:
if (gmView != nil) { [gmView change]; }
and added an NSLog in there, and nothing is being logged. So it looks like gmView is being considered nil. So I must be missing something in the declaration.

Declaring gmView as a certain type does not create a GameView object. Implicit in Lee's suggestion about checking it for nil, I think, is a suggestion that you ensure that it has been initialized somewhere. Somewhere in the setup of your MainView, probably in awakeFromNib, you need to do
Code:
gmView = [[GameView alloc] init];
or use whatever special initializer you might have set up for it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.