2013-05-15 3 views
-1

Продолжайте получать сообщение об ошибке на последней строке @implementation, говорящей о том, что реализация неполна. Не знаю, в чем проблема. Что может вызвать это? Я также разместил заголовок.Неполная реализация Errror

Добавлена ​​остальная часть кода из файла .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' в своем расширении класса? BTW - избавиться от строк '@ synthesize'. Те больше не нужны. И нет необходимости в объявлении метода в расширении класса. – rmaddy

ответ

1

Посмотрите на методы, перечисленные в файле .h. Теперь рассмотрим методы, которые вы фактически реализовали. SInce есть только два, довольно легко заметить, что вы не реализовали один из них.

Внедрение метода guessTap:.

0

Из кода я могу видеть interface declaration из

-(IBAction)guessTap:(id)sender;

Но вы не реализовали этот метод в .m файле

Смежные вопросы