Note that there are some explanatory texts on larger screens.

plurals
  1. PORestKit - RKFetchedResultsTableController : mapObjectsWithClass
    primarykey
    data
    text
    <p>Hi,</p> <p>I'm using a <code>RKFetchedResultsTableController</code> in order to fetch data from my WS and drive my tableview.</p> <p>I'm using <code>RKTableViewCellMapping</code> to map my model &amp; cells.</p> <p>Here's how I set up the cellMapping :</p> <pre class="lang-c prettyprint-override"><code>RKTableViewCellMapping *cellMapping = [RKTableViewCellMapping cellMapping]; cellMapping.cellClassName = @"CrudCategoryCell"; cellMapping.reuseIdentifier = @"CrudCategory"; cellMapping.rowHeight = 100; [cellMapping mapKeyPath:@"name.name" toAttribute:@"nameLabel.text"]; [cellMapping mapKeyPath:@"desc.desc" toAttribute:@"descLabel.text"]; [self.tableController mapObjectsWithClass:[CrudCategory class] toTableCellsWithMapping:cellMapping]; </code></pre> <p>As you can see, my model is represented by one class : <code>CrudCategory</code>.</p> <p>This class has two attributes : <code>name</code>, <code>desc</code>; respectively of type <code>CrudCategoryName</code> and <code>CrudCategoryDesc</code>.</p> <p>These classes inherit from <code>NSManagedObject</code>.</p> <p>When running the application :</p> <pre class="lang-c prettyprint-override"><code>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot build a tableView cell for object &lt;NSManagedObject: 0x6c4fb90&gt; (entity: CrudCategory; id: 0x6c4d900 &lt;x-coredata://FA7323F8-519D-4AA9-AC6E- BD30446B4C9B/CrudCategory/p210&gt; ; data: &lt;fault&gt;): No cell mapping defined for objects of type 'NSManagedObject'' </code></pre> <p>I was able to make it work by using :</p> <pre class="lang-c prettyprint-override"><code>[self.tableController mapObjectsWithClass:[NSManagedObject class] toTableCellsWithMapping:cellMapping]; </code></pre> <p>Instead of :</p> <pre class="lang-c prettyprint-override"><code>[self.tableController mapObjectsWithClass:[CrudCategory class] toTableCellsWithMapping:cellMapping]; </code></pre> <p>What I really don't get is that the exception states that there's no mapping for objects of type <code>NSManagedObject</code>, and when I use the <code>NSManagedObject</code> class instead of <code>CrudCategory</code> - which just inherits from <code>NSManagedObject</code> - everything's fine...</p> <p>Here's my environment :</p> <ul> <li>ios5 </li> <li>RestKit (last stable in github) </li> <li>ARC </li> <li>Storyboard</li> </ul> <p>If someone has an idea : )</p> <p>Thanks !</p> <p><strong>EDIT - Solved:</strong> I solved this issue in the datamodel by specifying the proper class for each entity. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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