title: Creating instance for core data class iphone
body: <p>I have a coredata class with a base class as <code>NSManagedObject</code>. I am using this class for storing data which are fetched from the server. I am storing it using Restkit Object Mapping. I am using same class for sending input to the server. For that I have created a <code>classA(NSObject)</code>, in which I created an instance for my core data class. I am passing object of <code>classA</code>. I can able to retrieve the data and store it into coredata using Restkit.</p>
  
  <p>Problem:</p>
  
  <ul>
  <li>When I try to fetch the details from database. I am getting 4 Values(actual value is 3 which is returned from server). From that one object becomes nil. I don't know the exact reason.</li>
  <li>I think the problem is with my core data instance. How can I create a instance for Core data class.</li>
  </ul>
  
  <p>Note: when I view my db, it shows only 3 rows. I think there is no problem with saving data in db. </p>
  
  <pre><code>NSFetchRequest* fetchRequest = [ClassA fetchRequest]; //ClassA is core data class
  NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"locationName" 
                                                               ascending:NO];
  [fetchRequest setSortDescriptors:[NSArray arrayWithObject:descriptor]];
  
  NSArray* Objects = [GHSLocation objectsWithFetchRequest:fetchRequest];
  </code></pre>
  
  <p>Thanks</p>