• 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
Core Data: IN with ordered set of keys?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: IN with ordered set of keys?


  • Subject: Core Data: IN with ordered set of keys?
  • From: Dan Treiman <email@hidden>
  • Date: Wed, 17 Apr 2013 16:41:00 -0500

I have a situation where I want to fetch an ordered array of managed objects which contain an ordered set of keys, and return the result in the same order as the input set:

    NSOrderedSet * orderedIDs = ...;
    NSFetchRequest * fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"MyEntityName"];
    NSPredicate * predicate = [NSPredicate predicateWithFormat: @"uuid IN %@", orderedIDs];
    NSArray * orderedObjects = [self.database.managedObjectContext executeFetchRequest:fetchRequest error:error];

By 'in the same order', I mean that I would like [[orderedIDs objectAtIndex:i] isEqual:[[orderedObjects objectAtIndex:i] uuid]] == YES for all valid indexes i.  I implemented a solution that orders the result after the fetch by iterating through orderedIDs and building a new array, but I feel like there should be a more elegant answer.  Any ideas?

	Thanks!
	- Dan Treiman
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSOutlineView Travails
  • Next by Date: Re: File by index?
  • Previous by thread: Re: File by index?
  • Next by thread: Detecting application bundle being moved
  • Index(es):
    • Date
    • Thread