임 간단한 "포인트 기반"응용 프로그램에서 작업 중입니다.UISlider 핵심 데이터 프로그래밍
설정에서 사용자가 슬라이더를 사용하여 "맛있는 음식"을 얻는 데 필요한 점수를 설정합니다.
-(IBAction) sliderChanged: (id)sender {
UISlider *slider = (UISlider *) sender;
int progressAsInt =(int)(slider.value +0.5);
NSString *newText = [[NSString alloc] initWithFormat:@"%d",progressAsInt];
sliderLabel.text = newText;
[newText release];
이 잘 작동하지만 어떻게 그래서 난 내 핵심 데이터 모델의 슬라이더 값을 저장하는 방법과 내 슬라이더 때보기로드 저장된 값을 표시해야합니까.
유 난 내 오류를 발견 :-D
헤이 gerry3을 좀 도와 수 있기를 바랍니다. 내가 함께 내 settingsViewController 내 사망 시각 객체를 설정하지 : SKOV
코드가 마법처럼 작동 NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription
entityForName:@"ToDo" inManagedObjectContext:_context]];
NSError *error = nil;
NSArray *array = [_context executeFetchRequest:request error:&error];
if (array == nil)
{
// Deal with error...
}
if(array.count > 0){
toDo = [array objectAtIndex:0];
} else { // no one to fetch - generate one
toDo = [NSEntityDescription
insertNewObjectForEntityForName:@"ToDo"
inManagedObjectContext:_context];
[toDo retain];
.....
감사
덕분에 난 내 응용 프로그램을 종료하고 응용 프로그램을 다시 시작하면 내가 추가하면되지만, 슬라이더, 다시 1 go's gerry3 - (무효)은 \t INT progressAsInt = ({저장 int) (pointSlider.value +0.5); \t toDo.goodiesPoints = [NSNumber numberWithInteger : progressAsInt]; – Skovie
핵심 데이터 스택을 설정하고 저장하려면 Apple의 (또는 다른 사람의) 예제 코드를 사용하고 있습니까? 관리 객체를 관리 객체 컨텍스트에 삽입하여 toDo 관리 객체를 만들고 있습니까? – gerry3
toDo는 goodiesPoints 속성이있는 ToDo 클래스의 속성입니다. 메신저 템플릿에서 하나를 사용하여, 그래서 밖으로 사과 NSManagedObjectContext * managedObjectContext; – Skovie