Note that there are some explanatory texts on larger screens.

plurals
  1. POTransient attributes and FetchRequest?
    primarykey
    data
    text
    <p>I have a transient attribute <code>titleFirstLetter</code> in the Book Entity:</p> <pre><code>- (NSString *)titleFirstLetter { NSString *tmpValue = nil; [self willAccessValueForKey:@"titleFirstLetter"]; if ([[self title] length] &gt; 0) { tmpValue = [[[self title] substringToIndex:1] uppercaseString]; if ([[NSScanner scannerWithString:tmpValue] scanInt:NULL]) { //return # if its a number tmpValue = @"#"; } } else { //sanity in case the attribute is not set. tmpValue = @""; } [self didAccessValueForKey:@"titleFirstLetter"]; return tmpValue; } </code></pre> <p>and I am trying to use this attribute as Section name but when I execute:</p> <pre><code> // Create the sort descriptors array. NSSortDescriptor *authorDescriptor = [[NSSortDescriptor alloc] initWithKey:@"titleFirstLetter" ascending:YES]; NSSortDescriptor *titleDescriptor = [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:authorDescriptor, titleDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; // Create and initialize the fetch results controller. NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"titleFirstLetter" cacheName:nil]; self.fetchedResultsController = aFetchedResultsController; fetchedResultsController.delegate = self; </code></pre> <p>I get this error:</p> <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath titleFirstLetter not found in entity &lt;NSSQLEntity Book id=1&gt;' </code></pre> <p>please help!</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.
 

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