2012-01-17 9 views
0

私はViewControllerにピッカーを持っており、その結果はラベルに印刷されます。ここでUILabelの結果をCoreDataに保存

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
{ 
    mlabel.text= [arrayNo objectAtIndex:row]; 
} 

コアにラベルの結果を保存コードです:私は、エラーコードここで

"[<__NSCFConstantString 0xf488> valueForUndefinedKey:]: this class is not key value coding-compliant for the key attribute.'. 

を取得し、CoreDataにこれらの結果を保存中に問題が生じていますラベルを出力コードがありますデータ:

- (IBAction)editSaveButtonPressed:(id)sender 
{ 

    if (!currentCategory) 
     self.currentCategory = (Entity *)[NSEntityDescription insertNewObjectForEntityForName:@"Entity" inManagedObjectContext:self.managedObjectContext]; 

    [self.currentCategory setAttribute:[mlabel text]]; //This is the line causing the error 

    NSError *error; 

    if (![self.managedObjectContext save:&error]) 
     NSLog(@"Failed to add new category with error: %@", [error domain]); 

    [self.navigationController popViewControllerAnimated:YES]; 
} 

なぜこのエラーが発生しますか?入力いただきありがとうございます。

答えて

1

の属性(したがってsetAttribute)がEntityで定義されているように見えます。

あなたはコアデータ上でこのチュートリアルをチェックアウトすることがあります:入力用http://www.raywenderlich.com/934/core-data-tutorial-getting-started

+0

感謝を。私は実際にチュートリアルをチェックしています。これはプロトコルやデリゲートについてのものです。 – PopUp

関連する問題