Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring int32 in Core Data model and Cocoa Error 1660
    primarykey
    data
    text
    <p>Edit: I was able to fix the presentation thing by changing the NSLog to present the actual int rather than the pointer. </p> <blockquote> <p>NSLog(@"id: %i", [[info valueForKey:@"idQ"] intValue]);</p> </blockquote> <p>Still have the Cocoa error 1660 to solve??</p> <p>I am doing my first tests with Core Data and is using this (http://www.raywenderlich.com/934/core-data-tutorial-getting-started) tutorial.</p> <p>I have then tried my own tests and is somewhat successful. However, the int32 (only 32 because of the tutorial) is resulting in a strange number. I do suspect it has something to do with NSNumber. The Cocoa error 1660 i believe has something todo with to long number in the output (input = 1 and output = 95518976). I guess this is a question of being a pointer and needs to present correctly, but what about the error.</p> <p>Could someone nice give me a hint how to fix this?</p> <pre><code>- (void)testingDBmodel { NSLog(@"&gt;&gt;testingDBmodel&lt;&lt;"); //=================DATABASE===================// // id // qDiff // question // qRightAnswer // qWrongAnswer1 // qWrongAnswer2 // qNr // qRegDate if (managedObjectContext == nil) { managedObjectContext = [(FamQuiz_v2AppDelegate *) [[UIApplication sharedApplication] delegate] managedObjectContext]; } NSManagedObjectContext *context = [self managedObjectContext]; NSManagedObject *famQuizInfo = [NSEntityDescription insertNewObjectForEntityForName:@"questions" inManagedObjectContext:context]; [famQuizInfo setValue:[NSNumber numberWithInt:1] forKey:@"idQ"]; [famQuizInfo setValue:@"qDiff1" forKey:@"qDiff"]; [famQuizInfo setValue:@"question1" forKey:@"question"]; [famQuizInfo setValue:@"qRightAnswer1" forKey:@"qRightAnswer"]; [famQuizInfo setValue:@"qWrongAnswer1_1" forKey:@"qWrongAnswer1"]; [famQuizInfo setValue:@"qWrongAnswer2_2" forKey:@"qWrongAnswer2"]; [famQuizInfo setValue:@"999" forKey:@"qNr"]; [famQuizInfo setValue:[NSDate date] forKey:@"qRegDate"]; NSError *error; if (![context save:&amp;error]) { NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]); } //==========READ DATABASE==============// NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"questions" inManagedObjectContext:context]; [fetchRequest setEntity:entity]; NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&amp;error]; for (NSManagedObject *info in fetchedObjects) { NSLog(@"id: %i", [info valueForKey:@"idQ"]); NSLog(@"qDiff: %@", [info valueForKey:@"qDiff"]); NSLog(@"question: %@", [info valueForKey:@"question"]); NSLog(@"qRightAnswer: %@", [info valueForKey:@"qRightAnswer"]); NSLog(@"qWrongAnswer1: %@", [info valueForKey:@"qWrongAnswer1"]); NSLog(@"qWrongAnswer2: %@", [info valueForKey:@"qWrongAnswer2"]); NSLog(@"qNr: %@", [info valueForKey:@"qNr"]); NSLog(@"qRegDate: %@", [info valueForKey:@"qRegDate"]); } [fetchRequest release]; </code></pre> <p>}</p> <p>The output:</p> <blockquote> <p>2010-12-03 01:11:54.097 Test_v2[11177:207] >>testingDBmodel&lt;&lt;<br> 2010-12-03 01:11:54.104 Test_v2[11177:207] Whoops, couldn't save: The operation couldn’t be completed. (Cocoa error 1660.)<br> 2010-12-03 01:11:54.112 Test_v2[11177:207] id:1<br> 2010-12-03 01:11:54.112 Test_v2[11177:207] qDiff: qDiff1<br> 2010-12-03 01:11:54.113 Test_v2[11177:207] question: question1<br> 2010-12-03 01:11:54.113 Test_v2[11177:207] qRightAnswer: qRightAnswer1<br> 2010-12-03 01:11:54.114 Test_v2[11177:207] qWrongAnswer1: qWrongAnswer1_1<br> 2010-12-03 01:11:54.114 Test_v2[11177:207] qWrongAnswer2: qWrongAnswer2_2<br> 2010-12-03 01:11:54.114 Test_v2[11177:207] qNr: 999<br> 2010-12-03 01:11:54.116 Test_v2[11177:207] qRegDate: 2010-12-03 01:11:54 +0100 </p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload