-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
4

3 回答 3

1

查看 .h 文件中列出的方法。现在看看你实际实现的方法。因为只有两个,很容易注意到您没有实现其中一个。

实现guessTap:方法。

于 2013-05-15T04:03:10.190 回答
0

interface declaration从你的代码我可以看到

-(IBAction)guessTap:(id)sender;

但是你还没有在.m文件中实现这个方法

于 2013-05-15T04:07:12.043 回答
0

guessTap:从接口中删除方法

于 2013-05-15T04:13:59.733 回答