現在、iPhoneでクイズゲームを作成しようとしているので、チュートリアルを見ましたが、xcodeが私のplistなどを理解していないようです:実行するとラベルが空白になります:.mファイルで:
- (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);
}
もちろん、すべてではなく、関連するコードを付けただけです。誰か助けてください??