我是objective C
的新手,我想阅读一个plist,而不是说该字符串是否具有此值并执行此操作。
我试过这个:
NSString *filePath = @"E/eg.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc]
initWithContentsOfFile:filePath];
NSString *value;value = [plistDict
objectForKey:@"lang"];
if (NSString *value = @"1") {
mySwitch3.on = YES;
}
答案 0 :(得分:7)
这是获取给定键的值并将其与另一个字符串进行比较的方法。
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *value = [plistDict objectForKey:@"lang"];
if ([value isEqualToString:@"1"]) {
mySwitch3.on = YES;
}
有关Objective-C的更多信息:Learning Objective-C A Primer
Plist编程:PropertyLists