내 앱의 일부 설정을 닫으면 plist 파일에 저장하려고 시도하고 앱이 시작될 때로드하려고합니다. 나는 NSArray 배열에 저장된 4 숫자가 있습니다. 파일을 변경하면 파일이 변경된 방식으로 앱이 시작되므로 로딩이 정상적으로 작동합니다.NSArray writeToFile returns "is deprecated"- iPhone SDK
이 코드는 잘 작동 :
- (void)LoadSettings {
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:kSaveFileLocation];
NSArray *array = [[NSArray alloc] initWithContentsOfFile:finalPath];
clockFaceImageSlider.value = [[array objectAtIndex:0] integerValue];
HourTypeSwitch.on = [[array objectAtIndex:1] integerValue];
touchRotationSwitch.on = [[array objectAtIndex:2] integerValue];
accelerometerRotationSwitch.on = [[array objectAtIndex:3] integerValue];
}
이 코드는 저장 라인까지 작동합니다
이- (void)SaveSettings {
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:kSaveFileLocation];
NSArray *array = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:clockFaceImageSlider.value], [NSNumber numberWithInt:HourTypeSwitch.on], [NSNumber numberWithInt:touchRotationSwitch.on], [NSNumber numberWithInt:accelerometerRotationSwitch.on], nil];
if (![array writeToFile:finalPath atomically:YES]) {
NSLog(@"error");
}
//The log does print error
}
아무도 내가이 PLIST에 저장할 수있는 방법을 알고 있나요?
~ 감사
고마워. 저장하는 값은 4 개뿐입니다. –