Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:34:06+00:00 2026-06-09T11:34:06+00:00

I want to use three sections for a tableview: New Issues = issues reported

  • 0

I want to use three sections for a tableview:

New Issues = issues reported on this date regardless of status.
Active Issues = issues reported prior to this date still requiring follow up.
Closed Issues = issues reported prior to this date, not requiring follow up.

I have a transient property which correctly reports the sections – 0,1,2 respectively.

I have tried numerous ways to get my NSFetchedResultsController to sort the results correctly for the tableview to display. I find you cannot sort on the transient property in the NSFetchedResultsController so I tried to sort like so:

     //create sort keys
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateStyle:NSDateFormatterShortStyle];
[df setTimeStyle:NSDateFormatterNoStyle];
NSString *nowString = [df stringFromDate:[NSDate date]];
NSDate *todayDateWithoutTime = [df dateFromString:nowString];
[df release];
NSSortDescriptor *sortIsNew = [[NSSortDescriptor alloc] initWithKey:@"dateReported" ascending:YES comparator:^(id obj1,id obj2){
    NSDate *date1 = obj1;
    NSDate *date2 = obj2;
    NSComparisonResult comparisonResult;
    if ([date1 timeIntervalSinceDate:todayDateWithoutTime] == 0) {
        if ([date2 timeIntervalSinceDate:todayDateWithoutTime] == 0) {
            comparisonResult = NSOrderedSame;
        } else {
            comparisonResult = NSOrderedAscending;
        }
    } else {
        if ([date2 timeIntervalSinceDate:todayDateWithoutTime] == 0) {
            comparisonResult =  NSOrderedDescending;
        } else {
            comparisonResult = NSOrderedSame;
        }
    }
    return comparisonResult;
}];
NSSortDescriptor *sortByFollowUp = [[NSSortDescriptor alloc] initWithKey:@"requiresFollowUp" ascending:NO];
NSSortDescriptor *sortByReportDate = [[NSSortDescriptor alloc] initWithKey:@"dateReported" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortIsNew, sortByFollowUp,sortByReportDate, nil];
[fetchRequest setSortDescriptors:sortDescriptors];

Not so sure my usage of the block is correct, but in any case it never gets called so far as I can tell. I put some log statements in there and they do not report. Apparently the “sortByFollowUp” and “sortByReportDate” descriptors work as expected, but not the “sortIsNew”. If there are no new Issues everything works fine. In any case where there are new Issues for that first section, the app crashes as the sorting does not match the sections.

I know I can do this very easily with straight up fetch requests and arrays. It only seems right to use the fetched results controller to avoid pulling the entire table of Issues into memory when most are unneeded and only a few will be displayed at any given moment. Can it really be this difficult to use it when you want custom sections?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:34:08+00:00Added an answer on June 9, 2026 at 11:34 am

    As I have not received any answers I am closing the question with my own conclusions.
    Saving the transient value as an attribute appears actually to be the simplest fix. I have experimented with variations of a combo NSFetchedResultsController and Custom array method but it seems you lose a lot of the benefits of the NSFetchedResultsController that way. You wind up having to chase down all the events received and refresh the arrays as applicable. It seems that you may as well skip the NSFetchedResultsController in that case and just go ahead and work with arrays of objects directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have markup like this: <p>one two three four</p> And I want to use
I have three tables (individuals, groups & recordlabels) and want use the information between
I want to use min(5,10) , or Math.max(4,7) . Are there functions to this
I have a form with three sections, and I want to allow the users
I want to use FastScroll for my history list and use dates for sections,
I want to use an Abstract action for JFileChooser buttons because there will be
I want to use the pear mail extension to send SMTP authenticated emails. There
I want to use NSString from one UIView in another UIView . There are
I want to use geoJSON-formatted Data in my iPhone app. THere is a JSON
I want to use leiningen to build and develop my clojure project. Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.