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 7566173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:20:41+00:00 2026-05-30T14:20:41+00:00

I have these objects that are unique except for two columns once of which

  • 0

I have these objects that are unique except for two columns once of which I am using as the display in the UITableView. The UITableView will often show duplicates due to this. I need to filter out these duplicates somehow.

Setting distinctResult on the FetchResult won’t work in this case since that limits the functionality of the NSFetchedResultsController and it requires that the REsultType be a NSDictionary instead of a subclass of managed object.

Doesn’t anyone have any idea how I can filter these duplicates out using a predicate?? Remember that every field on these objects is unique except for two of them.

-(NSFetchedResultsController *) fetchGroupedObjects:(NSString *)entityDescription 
                                      sortField:(NSString *)sortField 
                                     withPredicate:(NSPredicate *)predicate  {

BPRAppDelegate *delegate = (BPRAppDelegate *)[UIApplication sharedApplication].delegate;
NSManagedObjectContext *context = delegate.managedObjectContext;
//NSError *error;

//Fetch the data....
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription 
                               entityForName:entityDescription inManagedObjectContext:context];
[fetchRequest setEntity:entity];

NSSortDescriptor *groupDescription = [[NSSortDescriptor alloc]
                                    initWithKey:GROUP_NAME ascending:YES];
//Sort by Category Name
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
                                    initWithKey:sortField ascending:YES];

NSMutableArray *sorts = [[[NSMutableArray alloc] init] autorelease];

[sorts addObject:sortDescriptor];
[sorts addObject:groupDescription];


[fetchRequest setSortDescriptors:sorts];
//[fetchRequest setResultType:NSDictionaryResultType];
//[fetchRequest setPropertiesToGroupBy:[entity.propertiesByName valueForKey:CONTRACTOR_NAME];


if (predicate != nil)
  [fetchRequest setPredicate:predicate];


//NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];

//NSFetchResultsController

[fetchRequest setFetchBatchSize:20];

NSFetchedResultsController *fetchedResultsController = 
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest 
                                    managedObjectContext:context sectionNameKeyPath:GROUP_NAME 
                                               cacheName:nil]; //Don't use a cache
 [fetchRequest release];
 [sortDescriptor release];
 [groupDescription release];
 return fetchedResultsController; //You can't autorelease this thing... the requestor must  do that.

}

  • 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-05-30T14:20:43+00:00Added an answer on May 30, 2026 at 2:20 pm

    While it might be easier to set up an optional to-one relationship back to itself (say, “child”) so that you can then fetch with a NSPredicate where “child == nil”, you can certainly post-filter easily enough in pure objective C using [array enumerateObjectsUsingBlock:] or equivalent, and only add unique objects per your criteria to the resultant array.

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

Sidebar

Related Questions

I have a class that creates several IDisposable objects, all of these objects are
I have a Queue that contains a collection of objects, one of these objects
I have some business objects which use: Web.Configuration.WebConfigurationManager.AppSettings.Item(SomeSetting) Now that I'm breaking those objects
I have a class that has a number of fields, two of which are
I am using Distributed Objects (DO) in Objective-C. I have a server object that
I have a custom object that implements INotifyPropertyChanged. I have a collection of these
I have an XML that I want to load to objects, manipulate those objects
I have a class that has an list<Book> in it, and those Book objects
I have a class that has an list<Book> in it, and those Book objects
I have some classes that represent immutable objects (Quantity, Price, Probability). Is there some

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.