`好的,我正在尝试从我创建的 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>
所以我试图通过查看各种教程在代码中做到这一点,我只是新手,所以我知道我错了
那么我想将问题放在情节提要中创建的标签中,并与可能的答案相同????`
- (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"]];`