title: How to use CoreData in Apportable?
body: <p>I trying the full version of apportable and I have a problem with the CoreData:</p>
  
  <p>I have the correct features at configuration.json:</p>
  
  <pre><code>"FEATURES": ["opengles2","landscape","prefer_external_storage","write_external_storage","write_settings"],
  </code></pre>
  
  <ol>
  <li><p>Setting the storageURL where I want to store the DB:</p>
  
  <pre><code> #ifdef ANDROID
   //tried many different locations but not luck, I think there is the problem
   NSURL *storeURL = [NSURL URLWithString:@"/data/data/com.bluepiggames.zombieSlice/files/Documents/ZS_SuperDatabase.db"];
   #else
   NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"ZS_SuperDatabase"];
   #endif
  </code></pre></li>
  <li><p>Creating the persistenceCoordinatore:</p>
  
  <pre><code>NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                               [NSNumber numberWithBool:YES],
                               NSMigratePersistentStoresAutomaticallyOption,
                               [NSNumber numberWithBool:YES],
                               NSInferMappingModelAutomaticallyOption, nil];
  
  _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]
                   initWithManagedObjectModel: [self managedObjectModel]];
  </code></pre></li>
  <li><p>Finally, these is the place where the app crash:</p>
  
  <pre><code>if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&amp;error]) {
  NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
  //abort();
  </code></pre>
  
  <p>And no error prompt in the debugger, only a crash like these.</p>
  
  <pre><code>F/libc    (10177): Fatal signal 11 (SIGSEGV) at 0xe1a0d013 (code=1)
  D/dalvikvm( 7227): GC_CONCURRENT freed 387K, 12% free 6566K/7431K, paused 2ms+2ms
  D/IabHelper(10177): Querying SKU details.
  I/DEBUG   ( 8708): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  I/DEBUG   ( 8708): Build fingerprint: 'SoftWinnner/crane_a1002jhenergy/crane-a1002jhenergy:4.0.4/IMM76D/20120822:eng/test-keys'
  I/DEBUG   ( 8708): pid: 10177, tid: 10218  &gt;&gt;&gt; com.bluepiggames.zombieSlice &lt;&lt;&lt;
  I/DEBUG   ( 8708): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr e1a0d013
  I/DEBUG   ( 8708):  r0 63c40b68  r1 6412b13c  r2 6412b13c  r3 00000000
  </code></pre></li>
  </ol>
  
  <p>(EDIT) To solve this crash we must set the before:</p>
  
  <pre><code>  NSError *error = nil. //!!!!!
    if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&amp;error])
  </code></pre>
  
  <p>Now the problem is in a different place:</p>
  
  <pre><code>// Returns the managed object model for the application.
  // If the model doesn't already exist, it is created from the application's model.
  - (NSManagedObjectModel *)managedObjectModel
  {
      if (_managedObjectModel != nil) {
          return _managedObjectModel;
      }
      NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"ZSDataModel" withExtension:@"momd"];
      NSLog(@"Test managedModel found %@",modelURL);
  
      _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
      return _managedObjectModel;
  }
  </code></pre>
  
  <p>And the error is because the DataModel compiled not found. Anybody knows how to put the compiled DataModel "DataModel.momod" inside a apportable project?</p>
  
  <p>Thanks</p>