나는 현재 을 시도하여 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
어떻게하면됩니까? (빠른 답변 감사합니다!) – lea51294
NSLog (@ "% @", tempDict); – rdelmar