Questions tagged [nspredicate]

The NSPredicate class is used in Mac OS X and iOS development to define logical conditions used to constrain a search either for a fetch or for in-memory filtering.

The NSPredicate class is used in Mac OS X and iOS development to define logical conditions used to constrain a search either for a fetch or for in-memory filtering.

An example predicate:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lastName like[cd] %@) AND (birthday > %@)", lastNameSearchString, birthdaySearchDate];

Multiple predicates can be combined into a more complex predicate with NSCompoundPredicate.

Full reference available in Apple's docs for NSPredicate. Also refer to the Predicate Programming Guide.

2953 questions
1
vote
3 answers

Remove objects using NSPredicate

I have the folloving dictionary which has many sub dictionaries. How can I remove objects where isChanged = 1 from parent dictionary using NSPredicate? { "0_496447097042228" = { cellHeight = 437; isChanged = 1; }; …
Shamsiddin Saidov
  • 2,281
  • 4
  • 23
  • 35
1
vote
0 answers

predicate the time/date interval string (1 hour ago 1day ago 1 week ago) to set section headers in uitableview iphone like Alphabets predicate

In my table view i get the contacts from sqlite database into an NSmutableArray *(sort By Date)* and populate them into the tableview. So recently added contact is always added to the top of the table, fine. Now my requirement is to set Section…
user1811427
  • 359
  • 2
  • 6
  • 17
1
vote
0 answers

How to do a left join in Core Data?

In my iOS messaging app, I'd like to display a list of the newest messages a user have with his interlocutors. In other words, this view is an overview of all chats. I found an answer for an SQL query that I've tried on the sqlite file: SELECT m1.*…
Andreas
  • 183
  • 1
  • 10
1
vote
1 answer

NSPredicate and BeginsWith

I would like to figure out the NSPredicate that will search my Core data for words that begins with: For example: description field in the core data has text like this: My name is Mike My name is Moe My name is Peter My name is George If I search…
SMA2012
  • 161
  • 1
  • 3
  • 9
1
vote
1 answer

Distance Between Locations Using NSPredicate

So I have a Core Data with an entity containing a longitude and latitude as NSNumbers. I want the NSFetchRequest's Predicate to filter based on how far the object in the database's location is from my current location. This would require me to…
gsapienza
  • 351
  • 1
  • 3
  • 8
1
vote
0 answers

NSPredicate strings

I have a path string in Core Data store like /folder/file.doc I want to create a predicate which will find this string with expression like /dir/dir2/folder/file.doc But I can't just reverse key path and string like: [NSPredicate…
1
vote
4 answers

Unable to parse the format string nspredicate error when using apostrophe

I am getting this error when entering a keyword in my searchbox: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "(title CONTAINS[c] 'hj'" I enter any string ('hj' in this case)…
John Smith
  • 2,012
  • 1
  • 21
  • 33
1
vote
1 answer

Get a list of Keys from NSDictionary containing NSNumber bools where the value is @YES

I'm trying to get an array of keys where the value for the corresponding key in an NSDictionary is @YES. For EG,: Starting Dictionary: NSDictionary* dict = @{@"key1" : @YES, @"key2": @YES, @"key3": @NO, @"key4": @NO}; Desired Result: NSArray* array…
SimpsOff
  • 252
  • 3
  • 10
1
vote
2 answers

Identify chars in alphabetical sequence OBJ-C

I'm writting an iOS app that has a signup section. My client has these awful rules about validation that's driving me crazy. The newest rule is like this: Do not accept more than 3 chars in alphabetical order such as: "abcd", "eFgH", "jklM". But i…
JRafaelM
  • 861
  • 2
  • 10
  • 23
1
vote
2 answers

Core Data predicate to-many

I'm trying to find an object matching a string and a set of objects. My predicate looks like this: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@ and individuals CONTAINS %@", name, individuals]; I'm not getting any hits.…
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
1
vote
1 answer

Matching Square Brackets with a Regular Expression in Objective C

I couldn't find anything that specifically addressed how to find square brackets in predicates on Stack Overflow or on Google so I thought I would post it here and see if anyone can explain the solution. NSString *mstr =…
KWorkman
  • 41
  • 4
1
vote
1 answer

Putting data from a core database in an array

I have a core data database and I would like to show the data into a tableview. I have been searching on the web how to do that but I never can find it. NSEntityDescription *entitydesc = [NSEntityDescription entityForName:@"Host"…
1
vote
1 answer

How to get the file extension

How to give multiple check condition in NSPredicate [NSPredicate predicateWithFormat:@"SELF ENDSWITH %@ %@%@ ,doc,pdf,png]; it need to work and give me three type and give me output.
kiran
  • 4,285
  • 7
  • 53
  • 98
1
vote
1 answer

Matching Annotations on MKMapView to those in the source array that created them

I have an NSArray of custom objects which are called Proximity. I add these to the map by creating a new ProximityAnnotation like the following: // Add the annotations to the map if (self.proximityItems) { for (Proximity *proximity in…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
1
vote
1 answer

Filtering NSArray of NSDictionaries using NSPredicate

I have an array like this: NSArray* myArray=[NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys:@"123",@"imageid",@"Jeff",@"imagename", nil], [NSDictionary…
uspython
  • 483
  • 5
  • 18
1 2 3
99
100