Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have some suggestions, too big for a comment. </p> <p>1) after you create the WeaponsRanged, try reading them back:</p> <pre><code>for(NSDictionary *item in jsonWeaponRanged) { WeaponsRanged *wr = [NSEntityDescription insertNewObjectForEntityForName:@"WeaponsRanged" inManagedObjectContext:context]; NSLog(@"IS WR Realized? %@", wr ? @"YES" : @"NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO WR"); ///***/// wr.recoil = [item objectForKey:@"Recoil"]; ///***/// NSError *error; if(![context save:&amp;error]) NSLog(@"%@", [error localizedDescription]); } // Now lets see if we can retrieve them: { NSEntityDescription *entiRange = [NSEntityDescription entityForName:@"WeaponsRanged" inManagedObjectContext:context]; NSFetchRequest *frRanged = [[NSFetchRequest alloc] init]; [frRanged setEntity:entiRange]; NSError *errorRanged = nil; arrRange = [context executeFetchRequest:frRanged error:&amp;errorRanged]; NSLog(@"Wrote %i items, read back %i items", [jsonWeaponRanged count], [arrRange count] ); } </code></pre> <p>2) In the viewController reading WeaponsRanged, add an assert before the fetch on mod:</p> <pre><code> NSLog(@"IS moc set? %@", moc ? @"YES" : @"NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MOC"); </code></pre> <p>EDIT: </p> <p>3) Spread statements everywhere you access the MOC:</p> <pre><code>assert([NSThread isMainThread]); </code></pre> <p>[If you haven't used asserts before google and read up on the topic. These are a powerful tool for developers to find out about potential problems way before they manifest themselves in the gui or elsewhere. They are normally compiled out for release/distribution builds.]</p> <p>This will force an exception if the thread is not the main thread, and then let you track down the reason by following the stack trace.</p>
 

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