2013-05-15 47 views
-1

在最後一行@implementation行中出現錯誤,說實現不完整。不確定是什麼問題。什麼會造成這種情況?我也發佈了標題。不完整的實現錯誤

從.m文件中添加了其餘的代碼。

#import "mmViewController.h" 

@interface mmViewController() 
-(void)timerFired:(NSTimer*)theTimer; 

@end 

@implementation mmViewController 
@synthesize remainingTime, playerScore, scrambledWord; 


- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

-(void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    //Do any additional setup after loading the view, typically from a nib. 
    //Initialize the game model 
    gameModel = [[mmScramblerModel alloc] init]; 

    //Display the time, score and scrambled word 
    remainingTime.text = [NSString stringWithFormat:@"%i", gameModel.time]; 
    playerScore.text = [NSString stringWithFormat:@"%i", gameModel.score]; 
    scrambledWord.text = [gameModel getScrambledWord]; 

    //Start the game timer 
    gameTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 
               target:self 
               selector:@selector(timerFired:) 
               userInfo:nil 
               repeats:YES]; 
} 

-(void) endGameWithMessage:(NSString *)message { 
    //Call this method to end the game 

    //Invalidate the timer 
    [gameTimer invalidate]; 

    //Show an alert with the results 
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Game Over!" 
                message:message 
                delegate:self 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil]; 
    [alert show]; 
} 

-(void) timerFired:(NSTimer *)theTimer { 
    //The timer fires this method rougly every second 
    [gameModel timerTick]; 

    if(gameModel.time <= 0){ 
     remainingTime.text = 0; 
     [self endGameWithMessage:@"You are out of time. You lose!"]; 
    } 
    else 
     remainingTime.text = [NSString stringWithFormat:@"%i", gameModel.time]; 
} 

@end 








#import <UIKit/UIKit.h> 
#import "mmScramblerModel.h" 

@interface mmViewController : UIViewController { 
    mmScramblerModel* gameModel; 
    NSTimer* gameTimer; 
} 
-(IBAction)guessTap:(id)sender; 
-(void) endGameWithMessage:(NSString*) message; 

@property (weak, nonatomic) IBOutlet UITextField * guessText; 
@property (weak, nonatomic) IBOutlet UILabel * scrambledWord; 
@property (weak, nonatomic) IBOutlet UILabel * remainingTime; 
@property (weak, nonatomic) IBOutlet UILabel * playerScore; 

@end 
+0

你實現這兩種方法顯示在你的界面?你在類擴展中實現了'timerFired'方法嗎?順便說一句 - 擺脫'@ synthesize'線。那些不再需要了。在類擴展中也沒有必要使用方法聲明。 – rmaddy

回答

1

查看.h文件中列出的方法。現在看看你實際實現的方法。因爲只有兩個,所以很容易注意到你沒有實現其中的一個。

執行guessTap:方法。

0

從你的代碼中,我可以看到的interface declaration

-(IBAction)guessTap:(id)sender;

可是你有沒有在.m文件中實現這種方法