Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Complex sectionNameKeyPath issue
    primarykey
    data
    text
    <p>I am trying to create a NSFetchedResultsController using date and type.</p> <p>My Data looks like this :</p> <pre><code>{ @"date", NSDate, @"type", NSString } </code></pre> <p>This is what my NSManagedObject</p> <pre><code>- (NSString*)dayTypeStringOnly { NSCalendar *cal = [NSCalendar currentCalendar]; return [NSString stringWithFormat:@"%i%i%i%@", (int)[[cal components:NSYearCalendarUnit fromDate:self.startTime] year],(int)[[cal components:NSMonthCalendarUnit fromDate:self.startTime] month],(int)[[cal components:NSDayCalendarUnit fromDate:self.date] day], [self.type lowercaseString]]; } </code></pre> <p>Here is my NSFetchedResultsController:</p> <pre><code>NSFetchRequest *dataRequest = [NSFetchRequest fetchRequestWithEntityName:entityName]; [dataRequest setPredicate:kHiddenPredicate]; [dataRequest setFetchBatchSize:kMagicalRecordDefaultBatchSize]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"type" ascending:NO selector:@selector(caseInsensitiveCompare:)]; [dataRequest setSortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES], sortDescriptor]]; NSFetchedResultsController *dataFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:dataRequest managedObjectContext:[NSManagedObjectContext MR_defaultContext] sectionNameKeyPath:@"dayTypeStringOnly" cacheName:nil]; </code></pre> <p>I am getting this error:</p> <pre><code>Unresolved error Error Domain=NSCocoaErrorDomain Code=134060 "The operation couldn’t be completed. (Cocoa error 134060.)" UserInfo=0x10e847230 {reason=The fetched object at index 8 has an out of order section name '20131011pump. Objects must be sorted by section name'}, { reason = "The fetched object at index 8 has an out of order section name '20131011pump. Objects must be sorted by section name'"; </code></pre> <p>Can anyone see what I am doing wrong here?</p>
    singulars
    1. This table or related slice is empty.
    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