• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: fetch request with compound predicate doesn't sort properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fetch request with compound predicate doesn't sort properly


  • Subject: Re: fetch request with compound predicate doesn't sort properly
  • From: Ken Victor <email@hidden>
  • Date: Tue, 14 Mar 2006 15:30:56 -0800

At 3:25 PM -0800 3/14/06, Greg Herlihy wrote:
What does:

    [self defaultSortDescriptor]

return exactly?

return [NSArray arrayWithObject: [[[NSSortDescriptor alloc] initWithKey: @"accountsId" ascending: YES] autorelease]];


ken


Greg


On 3/14/06 2:55 PM, "Ken Victor" <email@hidden> wrote:

 i've done a little more "research" into this and am still
 (very/rather) confused! the problem doesn't appear to be related to
 whether or not the predicate is compound or not. instead, it seems to
 be related to whether or not the managed object context has been
 saved or not and to whether or not the fetch request is constructed
 programmatically or obtained from my object model. its easiest to
 summarize via the following table:

 context saved         fetch created programmatically         sorts properly
 ============       ===========================        ============
 yes                                  yes
 yes
 yes                                  no
 yes
 no                                   yes
 yes
 no                                   no
 no

 this appears to be the case even when the fetch request from within
 my model contains a non-compound predicate, ie, the fetch request in
 my model is the save as the one i create programmatically.

 so... is there some reason why a fetch request obtained via
      NSFetchRequest* request = [[[objectModel
 fetchRequestTemplateForName: fn] copy] autorelease];
      [request setSortDescriptors: [self defaultSortDescriptor]];
 should not sort the results if the MOC hasn't yet been saved?

 thanx,
 ken

 ps. just to add to the confusion, for case 4 above (where the context
 has not been saved), if i set the enitity and predicate of my
 programmatically created fetch request to the entity and predicate
 obtained from the request obtained from my model, it sorts properly!



At 5:34 PM -0800 3/12/06, Ken Victor wrote:
 if i use the following fetch request, i get back what i consider to
 be a properly sorted array:

 (entity: TaxCategory; predicate: (wasDeleted == 0); sortDescriptors:
 ((accountsId, ascending, compare:)); limit: 0)

 however, the following fetch request, with a compound predicate,
 doesn't sort the resulting array:

 (entity: TaxCategory; predicate: (name != 0 AND name MATCHES
 "^\\S.*" AND name MATCHES ".*\\S$" AND wasDeleted == 0);
 sortDescriptors: ((accountsId, ascending, compare:)); limit: 0)

 note that both requests DO return the proper set, its just that the
 result of the request with a compound predicate isn't sorted. i
 can't swear to this, but i believe this used to work prior to
 uprading to 10.4.5.

 can anyone shed some light on this for me?

 thanx,
 ken
  _______________________________________________
 Do not post admin requests to the list. They will be ignored.
 Cocoa-dev mailing list      (email@hidden)
 Help/Unsubscribe/Update your Subscription:
 This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: fetch request with compound predicate doesn't sort properly
      • From: Greg Herlihy <email@hidden>
References: 
 >Re: fetch request with compound predicate doesn't sort properly (From: Greg Herlihy <email@hidden>)

  • Prev by Date: Re: fetch request with compound predicate doesn't sort properly
  • Next by Date: [NSInputContext currentInputContext] crash
  • Previous by thread: Re: fetch request with compound predicate doesn't sort properly
  • Next by thread: Re: fetch request with compound predicate doesn't sort properly
  • Index(es):
    • Date
    • Thread