Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
- path = [path stringByAppendingPathComponent:@"List.plist"];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- if (![fileManager fileExistsAtPath:path]) {
- NSString *sourcePath = [[NSBundle mainBundle] pathForResource:CONTENT_DEFAULT ofType:PLIST];
- [fileManager copyItemAtPath:sourcePath toPath:path error:nil];
- }
- NSArray* newContent = [[NSArray alloc]initWithContentsOfFile:path];
- NSDictionary *Dict = [[NSDictionary alloc]initWithDictionary:[newContent objectAtIndex:2]];
- [Dict setValue:@"NO" forKey:@"Enabled"];
- [Dict writeToFile:path atomically:YES];
- *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionaryI 0x15de7ff0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Enabled.', or Im wrong in something?
- NSString *path = [[NSBundle mainBundle] pathForResource:@"List" ofType:@"plist"];
- NSString *savingPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
- NSArray* newContent = [[NSArray alloc]initWithContentsOfFile:path];
- NSMutableDictionary *Dict = [[NSMutableDictionary alloc]initWithDictionary:[newContent objectAtIndex:2]];
- [Dict setValue:@"NO" forKey:@"Enabled"];
- savingPath = [savingPath stringByAppendingPathComponent:@"Modified.plist"];
- [Dict writeToFile:savingPath atomically:YES];
- NSLog(@"newContent:%@",newContent);
- NSArray *newnew = [[NSArray alloc]initWithContentsOfFile:savingPath];
- NSLog(@"newnew:%@",newnew);
- *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (3) beyond bounds (2)'
- NSString *path = [[NSBundle mainBundle] pathForResource:@"List" ofType:@"plist"];
- NSString *savingPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
- savingPath = [savingPath stringByAppendingPathComponent:@"Modified.plist"];
- [Dict savingPath atomically:YES];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement