nspredicate

Format string for NSPredicate with @avg collection operator

别等时光非礼了梦想. 提交于 2019-12-11 04:23:55
问题 Is there a way to construct an NSPredicate so the following array can be filtered by average score larger than, say, 5? NSArray *objs = @[ @{@"scores":@[@3, @5, @2]}, @{@"scores":@[@5, @2, @8, @9]}, @{@"scores":@[@7, @1, @4]} ]; I have tried various combinations, of which this one seemed the most promising (considering that the key path @avg.self works to obtain the average value of numbers in an array through normal KVC): NSPredicate *pred = [NSPredicate predicateWithFormat:@"scores.@avg

NSPredicate filter to-Many with child object property

丶灬走出姿态 提交于 2019-12-11 03:56:07
问题 I have what I thought was a simple problem. I am attempting to filter some core data where I have a Parent object which has a to-many relationship with a child object and that child object has a string id. I want to get all the parent objects where no child object has a specific id. I have tried !(ANY... LIKE) as well as !(ANY..==) and NONE with like and == and ALL children.id != otherid My querying looks like: NSFetchRequest* fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Parent

NSPredicate to detect non-empty relationships within a subquery

喜欢而已 提交于 2019-12-11 03:25:06
问题 Given a core data entity setup as follows Entity A Bs -> B (many to many) Cs -> C (many to many) children -> Child (many to many) Entity B children -> Child (many to many) Entity C children -> Child (many to many) Child date I've wanted to query for Entity A's where any of the children (in Entity A, B, or C) have dates that pass some query like being greater than a specified date. Given the nested relationships some nested subqueries were required, so for checking all the Bs children from A

NSPredicate isKindOfClass only works for [myObject class] not for [MyClass class]

北战南征 提交于 2019-12-11 03:07:44
问题 Why is it that [MyClass class] fails to find the objects of the class I want in a predicate whereas [myObject class] works? See code example below. I want to be able to find objects of type MyClass in a set without needing to have a spurious instance of the class available. MyClass* myObject = [[MyClass alloc] init]; This doesn't work... NSPredicate* predicate = [NSPredicate predicateWithFormat:@"self isMemberOfClass: %@", [MyClass class]]; NSArray* predicateResults = [mySet

Search from NSArray using Predicate

瘦欲@ 提交于 2019-12-11 02:58:26
问题 my current array looks like below. i create this array format for sectionIndex table. so i can search from array and display search text using index table. arrContent = ( { key = A; value = ( Ac, Acting ); }, { key = B; value = ( Basketball, Baseball ); }, { key = C; value = ( Cat ); } { key = P; value = ( Panda, Peacock ); } ) My Search code looks like below. and it is working fine. -(void)searchText:(NSString *) text { [arrSearch removeAllObjects]; for (int i = 0; i < [arrContent count]; i+

Using a NSFetchedResultsController with an NSManagedObject and fetched properties

淺唱寂寞╮ 提交于 2019-12-11 02:45:46
问题 I have a database of Card s and Printing s that I have in one store (reference data) and my user's data of Container s and CardInstance s in another store (as Apple suggests). Each user's card is a table CardInstance that contains a specific printingID that corresponds with a specific printing of a card. I'm trying to use a NSFetchedResultsController to filter the values of the cards so that it can manage the groupings and stuff using reusable code. Again, here's the basic overview of the

CoreData performance: predicate on more to-many relationships

孤街浪徒 提交于 2019-12-11 02:43:01
问题 Using SQL data store, I have a model like this: Category <-->> Item Collection <-->> Item Brand <-->> Item Every left-side entity has a to-many relationship named items to the Item entity. Each one is the inverse of to-one Item relationships category , collection and brand respectively. I want to fetch all Brand objects with at least one Item in relation with a particular Collection AND a Category. In natural language, I want all the brands of items with particular category and a particular

NSPredicate acting strange in NSFetchedResultsController

本小妞迷上赌 提交于 2019-12-11 02:24:58
问题 I feel as if this should be very simple, but it's behaving strangely. I have 3 entities, with a relationship as such Entity A <-->> Entity B <<--> Entity C I have an NSFetchedResults controller and I'm trying to filter the results of Entity A using the following predicate. [NSPredicate predicateWithFormat:@"NONE entityB.entityC == %@", self.entityC]; When I try and run the app, the output shows no results. I can alter the predicate slightly to: [NSPredicate predicateWithFormat:@"ANY entityB

NSFetchedResultsController with NSPredicate not updating

送分小仙女□ 提交于 2019-12-11 01:56:27
问题 I fetch data from a Core Data-base and present them in a UITableView . I use a NSFetchedResultController to fetch the data. I want the user to be able to search in the database, and to do that I use a NSPredicate . The data is presented in the UITableView and everything works well until I set the NSPredicate to the NSFetchedResultController . I use this in the ViewDidLoad method: self.fetchedResultsController = nil; fetchedResultsController_ = nil; NSError *error = nil; if (![[self

How can I refresh a NSFetchedResultsController?

牧云@^-^@ 提交于 2019-12-11 00:38:38
问题 I have a NSFetchedResultsController which displays data in a UITableView. I'm using the boiler plate code provided by Xcode when choosing to create a Core Data project. I added the following predicate to the NSFetchRequest the NSFetchedResultsController uses (before NSFetchedResultsController is initialized): NSPredicate *predicate = [NSPredicate predicateWithFormat:@"deleted == NO"]; [fetchRequest setPredicate:predicate]; Now in another location of my app, I set the deleted property like so