-4
그래서 "View User Record"버튼을 클릭하면 뷰 컨트롤러의 Score와 Live 값을 표시하고 plist에 배열로 저장하려고합니다. 그리고 plist의 값이 테이블보기에 표시됩니다.데이터 지속성을 위해 plist를 사용해야합니다. 보기 컨트롤러에서 값을 plist에 저장 한 다음 그 값을 테이블보기에 표시하려면 어떻게해야합니까?
그래서 "View User Record"버튼을 클릭하면 뷰 컨트롤러의 Score와 Live 값을 표시하고 plist에 배열로 저장하려고합니다. 그리고 plist의 값이 테이블보기에 표시됩니다.데이터 지속성을 위해 plist를 사용해야합니다. 보기 컨트롤러에서 값을 plist에 저장 한 다음 그 값을 테이블보기에 표시하려면 어떻게해야합니까?
plist 파일에 값을 추가하려고 시도하십시오.
NSString* plistPath = nil;
NSFileManager* manager = [NSFileManager defaultManager];
if (plistPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Contents/Info.plist"])
{
if ([manager isWritableFileAtPath:plistPath])
{
NSMutableDictionary* infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
[infoDict setObject:[NSNumber numberWithBool:hidden] forKey:@"LSUIElement"];
[infoDict writeToFile:plistPath atomically:NO];
[manager changeFileAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate] atPath: [[NSBundle mainBundle] bundlePath]];
}
}
그리고 이것은 plist 파일에서 가치를 얻는 것입니다.
// Get the value for the "Bundle version" from the Info.plist
[mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"];
// Get the bundle identifier
[mainBundle bundleIdentifier];
// Reads the value of the custom key I added to the Info.plist
NSString *value = [mainBundle objectForInfoDictionaryKey:@"key"];
//Log the value
NSLog(@"Value = %@", value);
NSBundle* mainBundle = [NSBundle mainBundle];
는이 코드가 당신을 위해 유용 바랍니다.