Questions tagged [nscompoundpredicate]

`NSCompoundPredicate` is a subclass of `NSPredicate` used to represent logical “gate” operations (AND/OR/NOT) and comparison operations.

Comparison operations are based on two expressions, as represented by instances of the NSExpression class. Expressions are created for constant values, key paths, and so on.

In OS X v10.5 and later and in iOS, you can use NSCompoundPredicate to create an AND or OR compound predicate (but not a NOT compound predicate) using an array with 0, 1, or more elements:

  • An AND predicate with no subpredicates evaluates to TRUE.
  • An OR predicate with no subpredicates evaluates to FALSE.
  • A compound predicate with one or more subpredicates evaluates to the truth of its subpredicates.
24 questions
0
votes
1 answer

NSPredicate search comma separated value with array

Have a entity filed called "keyword" which containing comma separated value like "8275,8276,8277". Now using NSPredicate search those users whose keyword matching on this and the passing value is an NSArray. Trying to fetch using (keywords…
0
votes
1 answer

Combining "And" and "Or" on NSPredicates

I want to do something like this: NSPredicate(format: "name contains[cd] %@ AND (position == %@ OR position == %@), name, position1, position2) However, I've tried that and I keep getting serious Core Data application errors. I then tried using…
anders32
  • 295
  • 1
  • 4
  • 11
0
votes
0 answers

Is it possible to include a [NSPredicate predicateWithBlock:] in a NSCompoundPredicate?

I'm trying to make a big filter with a NSCompoundPredicate that includes a BlockPredicate but I get this error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Problem with subpredicate…
EnriMR
  • 3,924
  • 5
  • 39
  • 59
0
votes
0 answers

NSCompoundPredicate not filtering array

To test out a restaurant searching app I included 4 test restaurants in a JSON file which populate a table view correctly with their corresponding properties. In 3 text fields I filter the array with a name, average entree price and rating, yet when…
Echizzle
  • 3,359
  • 5
  • 17
  • 28
0
votes
2 answers

NSCompoundPredicate construction

Say I have this array of predicates in the feedDays array: <__NSArrayM 0x7ff7f3cd1040>( feedDay == 1, feedDay == 2, feedDay == 4 ) I need to AND it with this statusPredicates array: <__NSArrayM 0x7ff7f3cd1070>( is_neutered == 0 AND…
soleil
  • 12,133
  • 33
  • 112
  • 183
0
votes
2 answers

Fetching entities whose many-to-many relationship contains all terms

I have a model with a Verse entity that has a many-to-many relationship to a Word entity. I'd like to find verses that contain all words that a user is searching for. I'm guessing that it could be done with a predicate like "ANY words.word == %@…
user4151918
0
votes
1 answer

Compound predicate not returning the results

I'm stuck with this problem for a while now I can't seem to think of a way to get it right. I'll try to explain it as clear as I can. There are 3 entities in my core data model. Workplace, Patient and Handover. A Workplace can have multiple…
Isuru
  • 30,617
  • 60
  • 187
  • 303
0
votes
1 answer

how to create compoundpredicate within nsFetchRequest that filters by two parameters of different entity

Some background info on my datamodel: manufacturer <-->> item <<-->> tag I currently generate a list of items by a fetchrequest: - (NSFetchRequest*) rankingRequestForItem:(Item*)item { NSFetchRequest* r = [NSFetchRequest…
user3411663
  • 1,041
  • 1
  • 9
  • 12
0
votes
1 answer

How can I get NSManagedObject from NSExpression?

I have this predicate: DG == (entity: DG; id: 0x8c91140 ; data: ) How can I restore NSManagedObject from…
János
  • 32,867
  • 38
  • 193
  • 353
1
2