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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to