title: Core Data NSManagedObject Insert and Save Methods
body: <p>Is there an easier way to do something like the following in Core Data:</p>
  
  <pre><code>Entry *entry = [[Entry alloc] init];
  entry.name = @"An Entry";
  [entry save];
  </code></pre>
  
  <p>I realize you don't have to allocate an NSManagedObject, have to insert directly into the context like the following:</p>
  
  <pre><code>Entry *entry = [NSEntityDescription insertNewObjectForEntityForName:@"Entry"
                           inManagedObjectContext:[self managedObjectContext]];
  </code></pre>
  
  <p>But this is a lot of code. Also I would like to save by just messaging rather than have to save the entire context:</p>
  
  <pre><code>NSError *error = nil;
  NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
  if (managedObjectContext != nil)
  {
      if ([managedObjectContext hasChanges] &amp;&amp; ![managedObjectContext save:&amp;error])
      {
          NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
          abort();
      } 
  }
  </code></pre>
  
  <p>Could I put these in an NSManagedObject abstract class and have my managed objects extend that abstract class? Basically, I'm just trying to encapsulate more in my models and write less code in my controllers. Any help appreciated.</p>