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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:59:17+00:00 2026-05-31T10:59:17+00:00

I’m having problem how to formulate NSPredicate to get correct data. I have three

  • 0

enter image description here

I’m having problem how to formulate NSPredicate to get correct data. I have three entities (Offer, List, Item) and an entity OfferMatch wchich matches an offer for each pair (List, Item).

I’m trying to get all offers from selected list, but different Items can have the same offer and when I fetch them I get some offers duplicated. I want to get distinct answer whithout any offers showed more than once.

I was trying to use:

[NSFetchRequest setResultType:NSDictionaryResultType] 
[NSFetchRequest ssetPropertiesToFetch: 
[NSFetchRequest ssetReturnsDistinctResults:YES]

but NSFetchResultsController is not supporting NSDictionaryResultType at all.

Here is a sample code when I set up NSFetchResultsController:

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    // I'm interested in both Offer of OfferMAtch entity to get, so you can select more usefull for you 
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Offer or OfferMatch" inManagedObjectContext:[CoreDataHandler context]];
    [request setEntity:entity];
    // I want to get all Offers from selected List, but with each one being only once
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@" ---- HERE IS MAGIC --- "];
    [request setPredicate:predicate];
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"categoryID" ascending:NO];
    NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"descriptionString" ascending:NO];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, sortDescriptor2, nil];
    [request setSortDescriptors:sortDescriptors];
    [sortDescriptors release];
    [sortDescriptor release];
    [sortDescriptor2 release];
    if (self=[[OfferFetchResults alloc] 
              initWithFetchRequest:request 
              managedObjectContext:[CoreDataHandler context] 
              sectionNameKeyPath:@"categoryID"
              cacheName:nil]) 
    {
        self.delegate = self;
    }
    [request release];
    [self performFetch:nil];

I’m not good in formulating complex NSPredicates. I hope someone will help me, because NSPredicate Programming Guide wont’ help me.

  • 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-31T10:59:19+00:00Added an answer on May 31, 2026 at 10:59 am

    Solved … I quit trying to prepare NSPredicate. I simple changed DB model deleting entity OfferMatch and then adding appropriate relationships beetwen main Entities directly.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.