0
我嘗試寫test.plist文件,該文件被保存在我的支持文件, 這裏是我的代碼
- (IBAction)acceptAction:(id)sender {
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *pathToFile = [mainBundle pathForResource:@"test" ofType:@"plist"];
NSMutableDictionary *md = [[NSMutableDictionary alloc] initWithContentsOfFile:pathToFile];
[md setValue:@"yes" forKey:@"hasAgree"];
[md writeToFile:pathToFile atomically:YES];
}
- (IBAction)declineAction:(id)sender {
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *pathToFile = [mainBundle pathForResource:@"test" ofType:@"plist"];
NSMutableDictionary *md = [[NSMutableDictionary alloc] initWithContentsOfFile:pathToFile];
NSString *value;
value = [md objectForKey:@"hasAgree"];
NSLog(@"value is %@", value);
}
接受wrtting動作按鈕.. 下降對接行動對於閱讀它.. 但不工作,有什麼建議嗎?