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
6
votes
1 answer

Create complicated NSCompoundPredicate in swift 3

I want to create a complicated NSCompoundPredicate in swift 3, however, I don't know how to do this. Suppose I have 5 predicates (p1,p2,p3,p4,p5). I want to implement below conditions: compound1 = (p1 AND p2 AND p3) // NSCompoundPredicate(type:…
Amir Shabani
  • 690
  • 2
  • 14
  • 36
6
votes
3 answers

NSCompoundPredicate

I'm trying to filter a UITableView's data using a UISearchDisplayController and NSCompoundPredicate. I have a custom cell with 3 UILabels that I want to all be filtered within the search, hence the NSCompoundPredicate. // Filter the array using…
3
votes
1 answer

NSCompoundPredicate and Cloudkit

I'm trying to do this with a compound predicate using Cloudkit, but Xcode error says "Unexpected Expression". Anyone know what is wrong with my code? Appreciate any help! let userRef = CKReference(recordID: userID, action: .None) let…
Renee Olson
  • 267
  • 1
  • 15
2
votes
2 answers

How to create NSCompoundPredicate with "empty" predicate

I try to combine more individual predicates into one via NSCompoundPredicate but it may happen that one or more predicates are not constructed because all objects should be retrieved from CoreData entity (so no predicate is actually needed). if…
Dawy
  • 770
  • 6
  • 23
2
votes
1 answer

NSPredicate to filter beacon according to UUID, major and minor raising exception

I have a beacons array having a collection of CLBeacon and I would like to get only the beacon which matches a given uuid, major and minor in NSPredicate. Below is the code in Object C which is generating an exception because of UUID in the…
Simant
  • 3,142
  • 4
  • 32
  • 61
2
votes
3 answers

How to use NSpredicate on array of nested dictionaries

Array format: { "sku": "NikeL101Black", "name": "Nike Black shirt -L", "attribute_set_id": 4, "price": 30, "status": 1, "visibility": 1, "type_id": "simple", "created_at": "2015-12-01 23:02:07", "updated_at":…
nr5
  • 4,228
  • 8
  • 42
  • 82
2
votes
1 answer

NSCompoundPredicate error in Xcode 6.1

Back in Xcode 6, in a project using Core Data I had the following line. It worked fine. fetchRequest.predicate = NSCompoundPredicate(type: .AndPredicateType, subpredicates: [predicate, datePredicate]) predicate and datePredicate are of NSPredicate…
Isuru
  • 30,617
  • 60
  • 187
  • 303
2
votes
1 answer

Building an NSCompoundPredicate from array values in Swift

List item So I'm trying to set up a request with multiple conditions in Swift. The SQL equivalent to: select BOARDID from BOARD where BOARDID not like "someBoard" and BOARDID not like "anotherBoard" .. I have an array of strings and I'm trying…
Pirijan
  • 3,430
  • 3
  • 19
  • 29
2
votes
2 answers

NSCompoundPredicate Mixing AND and OR

I have started using NSCompoundPredicate to combine my predicates, however have a problem. Here is an example of one predicate: Aircraft *obj = (Aircraft *)[self.managedObjectContext objectWithID:objID]; if ([predicateAircraft.predicateFormat…
Josh Kahane
  • 16,765
  • 45
  • 140
  • 253
1
vote
1 answer

Using NSCompoundPredicate with a list of lists

I have a large list of recipes and inside of each recipe is a list of ingredients. I want to write a query that will return a list of recipes that have both "egg" and "butter". Here is a quick screenshot of the first few recipes in my CKRecord Type.…
Willy Mac
  • 21
  • 4
1
vote
1 answer

NSPredicate: search for an array of values in relation, NOT

I'm a bit lost, and I hope you can help me. I have two arrays let stars = ["Paul", "Ringo"] let visitors = ["bob", "mary"] Then I have Core Data entities Rockstar and Person. And a one-to-many relation fans between the two. Now I want to find a…
Sjakelien
  • 2,255
  • 3
  • 25
  • 43
1
vote
2 answers

Translate a nested Conditional If Statement into a complex NSCompoundPredicate

I'm writing a macOS target for an old iOS based project using SwiftUI. Is's a Core Data driven application and for the macOS target, I've successfully implemented generic List using a dynamic @FetchRequest, mostly as described by Paul Hudson in his…
1
vote
1 answer

Multiple NSPredicates to single Array values in ios

In my projects i'm working in NSPredicate i already worked for a single NSPredicate but now i need to Use multiple NSPredicate.Here i'm having one array, from this array i want to filter by the multiple cases, I'm having three check box like that,…
Test
  • 177
  • 1
  • 1
  • 13
1
vote
1 answer

NSPredicate for filter objects whoes string is BEGINSWITH special characters

I have one scenario where I want to filter the objects of NSArray who have NSDictionary object and every object have key name. I want to filter with that number of objects whose name key value should be starting with special characters or numeric…
Ravi B
  • 1,574
  • 2
  • 14
  • 31
0
votes
1 answer

iOS Swift Compound Predicate

I'm trying to do a search for specific items within Core Data I have an Entity Colour, which has a NSSet of ProjectColour Entities. The ProjectColour Entities have a field called project which is a Project Entity, and two int fields called fullLeft…
Ceri Turner
  • 830
  • 2
  • 12
  • 36
1
2