Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I created a Sample for a Core Data Test environment on github <a href="http://github.com/mbrugger/CoreDataDependentProperties/blob/master/LPAutomatedObserving/Tests/ManagedObjectSenTestCase.m" rel="nofollow noreferrer">http://github.com/mbrugger/CoreDataDependentProperties/blob/master/LPAutomatedObserving/Tests/ManagedObjectSenTestCase.m</a></p> <p>Inherit your testcases from ManagedObjectSenTestCase.m/h and adjust the following two lines with your test target bundle identifier and data model name</p> <pre><code> NSBundle* bundle = [NSBundle bundleWithIdentifier:@"com.yourcompany.ModelTest"]; NSString* path = [bundle pathForResource:@"DataModel" ofType:@"mom"]; </code></pre> <p>Code samples:</p> <pre><code>-(void) setUp { pool = [[NSAutoreleasePool alloc] init]; NSMutableSet *allBundles = [[[NSMutableSet alloc] init] autorelease]; [allBundles addObjectsFromArray:[NSBundle allBundles]]; NSBundle* bundle = [NSBundle bundleWithIdentifier:@"com.yourcompany.ModelTest"]; NSString* path = [bundle pathForResource:@"DataModel" ofType:@"mom"]; NSURL* modelURL = [NSURL URLWithString:path]; self.model = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] autorelease]; self.coordinator = [[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.model] autorelease]; LPManagedObjectContext* tempContext = [[[NSManagedObjectContext alloc] init] autorelease]; [tempContext setPersistentStoreCoordinator:coordinator]; [tempContext setRetainsRegisteredObjects:YES]; self.context = tempContext; } -(void) tearDown { NSLog(@"BEGIN: ManagedObjectSenTestCase tearDown"); @try { self.context= nil; self.model = nil; self.coordinator = nil; [pool release]; pool = nil; } @catch (NSException * e) { NSLog(@"%@",e); NSLog(@"%@", [e callStackSymbols]); NSLog(@"context reset failed!"); @throw(e); } NSLog(@"END: ManagedObjectSenTestCase tearDown"); } </code></pre> <p>This sample creates the core data stack and you can insert entities into the created context for testing.</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