0

Sample code below. Basically, in the code below, Game creates a bunch of objects called of type DragView. From within these DragView objects when touchesBegin is fired, I need it to call back to a method adjustScore within Game to adjust the score.

@interface Game : UIViewController
{
}
@end

@Implementation Game

DragView *dragger;

- (void)loadView
{
dragger = [[DragView alloc] initWithFrame:dragRect];  
    //simplified...code actually makes lots of these
}

+ (void) adjustScore
 {
NSLog(@"This is called from within DragView");
//does some more stuff…
}


@end


@interface DragView : UIImageView
{
CGPoint startLocation;
}
@end

@implementation DragView

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{   
NSLog(@"Touched");

///// help needed here to call "adjustScore" in Game above /////

} 
4

1 回答 1

0

adjustScore是一个类方法。只需使用:

[Game adjustScore];
于 2013-09-09T23:20:49.803 回答