Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1 - Yes. It is possible. When you create your mapping file, make sure you change the relationship's type from an NSSet to an NSArray, like so:</p> <pre><code> @class Tags @interface Entity : NSManagedObject ... @property (nonatomic, retain) NSOrderedSet *tags; ... @end @interface Entity (CoreDataGeneratedAccessors) ... - (void)addEntityTags:(NSOrderedSet *)values; - (void)removeEntityTags:(NSOrderedSet *)values; ... @end </code></pre> <p>Change to:</p> <pre><code> @class Tags @interface Entity : NSManagedObject ... @property (nonatomic, retain) NSArray *tags; ... @end @interface Entity (CoreDataGeneratedAccessors) ... - (void)addEntityTags:(NSArray *)values; - (void)removeEntityTags:(NSArray *)values; ... @end </code></pre> <p>2 - You can specify a sort descriptor when creating your fetch request, like so:</p> <pre><code> NSFetchRequest *fetchRequest [NSFetchRequest new]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entity" inManagedObjectContext:myManagedObjectContext]; [fetchRequest.setEntity: entity]; [fetchRequest setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"tags" ascending:&lt;YES|NO&gt;]]; [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"ANY tags == %@", yyy]]; NSFetchResultsController *myFetchResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:myManagedObjectContext setcionNameKeyPath:nil cacheName:nil]; myFetchResultsController.delegate = self; [fetchRequest release]; // Forget that if using ARC. NSError *error = nil; if (![myFetchResultsController performFetch:&amp;error]) { NSLog(@"Failed to fetch data: %@", error); } </code></pre> <p>3 - If you use the property, you shouldn't need to specify a predicate for your tags. If you want to further sort your tags, you can simply use a sort descriptor on that array, like this:</p> <pre><code> NSSortDescriptor *tagDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"&lt;tags field to sort on&gt;" ascending:&lt;YES|NO&gt;]; NSArray *sortedTags = [tagsProperty sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptors]]; </code></pre> <p>You can simply read from that property for your tags.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload