는 원래 PLIST는 사전의 배열을 포함
Click to see the images 이미지입니다
NSString *plistPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
plistPath = [plistPath stringByAppendingPathComponent:@"PassaveData.plist"];
NSMutableArray* newContent = [[NSMutableArray alloc]initWithContentsOfFile:plistPath];
NSMutableDictionary *Dict = [[NSMutableDictionary alloc]initWithDictionary:[newContent objectAtIndex:1]];
[Dict setValue:@"newVALUE" forKey:@"name"];
[Dict writeToFile:plistPath atomically:YES];
:
이
는 코드입니다. 새 사전을 만든 다음 원본 배열 기반 plist를 새 사전 하나만 덮어 씁니다. 로드 된 배열을 업데이트 된 사전으로 업데이트 한 다음 전체 업데이트 된 배열을 작성해야합니다.
NSMutableArray *newContent = [[NSMutableArray alloc] initWithContentsOfFile:plistPath];
NSMutableDictionary *dict = [newContent[1] mutableCopy];
dict[@"name"] = @"newVALUE";
newContent[1] = dict;
[newContent writeToFile:plistPath atomically:YES];
배열 및 사전에 최신 구문을 사용합니다.
원래의 .piist 파일이 아닌 문서 디렉토리에만 해당 업데이트 데이터가 있다고 생각합니다. –
처음 빌드 후 앱 이름을 변경하고 싶습니다. 어떻게 변경할 수 있습니까? 나는 이미 시도했다 [plistDict setValue : @ "com.xyz.Getdata"forKey : @ "CFBundleIdentifier"]; [plistDict setValue : @ "Getdata"forKey : @ "CFBundleName"]; [plistDict setValue : @ "MyProject"forKey : @ "CFBundleDisplayName"]; –
@BhumeshPurohit 앱의 리소스 번들에있는 파일을 업데이트 할 수 없습니다. 읽기 전용입니다. – rmaddy