嗨,我正在尝试从 plist 中读取值,这就是我的 plist 看起来像 atm
<plist version="1.0">
<array>
<dict>
<key>Title</key>
<string>Mickey Mouse</string>
<key>Image</key>
<string>mickeymouse.png</string>
<key>Hint1</key>
<string>Hint 1</string>
<key>Hint2</key>
<string>Hint 2</string>
<key>Hint3</key>
<string>Hint 3</string>
</dict>
<dict>
<key>Title</key>
<string>Peter Pan</string>
<key>Image</key>
<string>peterpan.png</string>
<key>Hint1</key>
<string>Hint 1</string>
<key>Hint2</key>
<string>Hint 2</string>
<key>Hint3</key>
<string>Hint 3</string>
</dict>
</array>
</plist>
这是我正在使用的代码但是它只是崩溃了。
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *questionNumber = [NSMutableString stringWithFormat:@"Item 0"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Level1" ofType:@"plist"];
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:path];
NSDictionary *questionNumberDictionary = [array objectForKey:questionNumber];
NSString *questionTitle = [questionNumberDictionary objectForKey:@"Title"];
NSString *questionImage = [questionNumberDictionary objectForKey:@"Image"];
NSString *questionHint1 = [questionNumberDictionary objectForKey:@"Hint1"];
NSString *questionHint2 = [questionNumberDictionary objectForKey:@"Hint2"];
NSString *questionHint3 = [questionNumberDictionary objectForKey:@"Hint3"];