[ios] plist 읽어오기 및 쓰기
//plist 불러오기
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
plistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"userPlist.plist"];
successPlist = [fileManager fileExistsAtPath:plistPath];
if(!successPlist){
//file does not exist. So look into mainBundle
NSString *defaultPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"userPlist.plist"];
successPlist = [fileManager copyItemAtPath:defaultPath toPath:plistPath error:&error];
}
//plist객체
plistDict =[[NSMutableDictionary alloc]initWithContentsOfFile:plistPath];
//plist 쓰기
NSMutableDictionary *infoDict = [[NSMutableDictionary alloc]initWithContentsOfFile:plistPath];
[infoDict setObject:@"1" forKey:@"login_type"];
[infoDict writeToFile:plistPath atomically:YES];