0
`好了,所以我想拉的問題和可能的答案由我創建從plist中檢索數據
<key>Question1</key>
<string></string>
<key>Answer1</key>
<array/>
<key>4</key>
<string>A</string>
<key>2</key>
<string>B</string>
<key>3</key>
<string>C</string>
所以我試圖做到這一點的代碼看起來各種教程的plist文件,我我只是新來的,所以我知道我有這一切錯誤
所以,然後我想把問題放在故事板中創建的標籤和相同的可能的答案? `
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *listPath = [[self docDir]stringByAppendingPathComponent:@"work.plist"];
if (![[NSFileManager defaultManager]fileExistsAtPath:listPath]) {
[[NSFileManager defaultManager] copyItemAtPath:[[NSBundle mainBundle]pathForResource:@"work" ofType:@"plist"]toPath:listPath error:nil];
}
NSMutableArray *array = [NSMutableArray arrayWithContentsOfFile:listPath];NSLog(@"count: %i", [array count]);
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
propertyListFromData:@"work.plist";
self.firstQuestion = [temp objectForKey:@"Question1"];
self.firstanswer = [NSMutableArray arrayWithArray:[temp objectForKey:@"Answer"]];`