我目前嘗試在iphone上做一個問答遊戲,所以我看到一個教程,但它似乎xcode不明白我的plist或東西:我的標籤是空白,當我運行它: 我.m文件:從plist回覆信息
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
questionNumber = 0;
NSString * path = [[NSBundle mainBundle] pathForResource:@"Propriety List" ofType:@"plist"];
if (path) {
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile: path];
self.Question = [tempDict objectForKey:@"Root"];}
currentQuestion = -1;
}
-(void) showNextQuestion {
currentQuestion++;
if (currentQuestion < [self.Question count]) {
NSDictionary *nextquestion = [self.Question objectAtIndex:currentQuestion];
self.Answear = [nextquestion objectForKey:@"QuestionAnswear"];
self.labelQuestionTitle.text = [nextquestion objectForKey:@"QuestionTitle"];
self.labelAnswearA.text = [nextquestion objectForKey:@"A"];
self.labelAnswearB.text = [nextquestion objectForKey:@"B"];
self.labelAnswearC.text = [nextquestion objectForKey:@"C"];
self.labelAnswearD.text = [nextquestion objectForKey:@"D"];
self.labelAnswearE.text = [nextquestion objectForKey:@"E"];
}
else {
// Game over
}
}
- (IBAction)buttonPressedA:(id)sender{
if ([self.Answear isEqualToString:@"A"]) {
numCorrect++;
NSLog(@"%d", numCorrect);
}
當然我只是把相關的代碼,而不是全部。 有人可以幫忙嗎?
如果你記錄tempDict,你會得到什麼? – rdelmar 2013-02-12 19:26:21
我該怎麼做? (謝謝你的快速回答!) – lea51294 2013-02-12 20:14:27
NSLog(@「%@」,tempDict); – rdelmar 2013-02-12 20:50:34