Objective c 不完整的实现错误
在最后一行@implementation行中不断出现错误,表示实现未完成。不知道问题出在哪里。这是什么原因造成的?我也贴了标题 添加了.m文件中的其余代码Objective c 不完整的实现错误,objective-c,Objective C,在最后一行@implementation行中不断出现错误,表示实现未完成。不知道问题出在哪里。这是什么原因造成的?我也贴了标题 添加了.m文件中的其余代码 #import "mmViewController.h" @interface mmViewController () -(void)timerFired:(NSTimer*)theTimer; @end @implementation mmViewController @synthesize remainingTime, pl
#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
#导入“mmViewController.h”
@接口mmViewController()
-(void)timerFired:(n计时器*)计时器;
@结束
@mmViewController的实现
@综合剩余时间、球员核心、争夺德沃德;
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
-(无效)viewDidLoad
{
[超级视图下载];
//加载视图后,通常从nib执行任何其他设置。
//初始化游戏模型
gameModel=[[mmScramblerModel alloc]init];
//显示时间、分数和加扰单词
remainingTime.text=[NSString stringWithFormat:@“%i”,gameModel.time];
playerScore.text=[NSString stringWithFormat:@“%i”,gameModel.score];
scrambledWord.text=[gameModel getScrambledWord];
//启动游戏计时器
gameTimer=[NSTimer scheduledTimerWithTimeInterval:1.0
目标:自我
选择器:@selector(timerFired:)
用户信息:无
重复:是];
}
-(void)endGameWithMessage:(NSString*)消息{
//调用此方法结束游戏
//使计时器失效
[游戏计时器失效];
//显示带有结果的警报
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“游戏结束!”
信息:信息
代表:赛尔夫
取消按钮:@“确定”
其他按钮:无];
[警报显示];
}
-(void)timerFired:(n计时器*)计时器{
//计时器每秒都会触发此方法
[gameModel timerTick];
如果(gameModel.time查看.h文件中列出的方法。现在查看您实际实现的方法。因为只有两种方法,很容易注意到您没有实现其中的一种
实现guessTap:
方法。从您的代码中,我可以看到
-(iAction)猜测点击:(id)发送者;
但是您没有在.m
文件中实现此方法从接口中删除猜测点击:
方法您实现了界面中显示的两个方法吗?您在类扩展中实现了timerFired
方法吗?顺便说一句-去掉@synthesis
行。这些都不再需要了e、 在类扩展中也不需要方法声明。