nspredicate

Writing an NSPredicate for 'CONTAINED_BY' text query

徘徊边缘 提交于 2019-12-11 12:27:29
问题 I am trying to construct a query of a Core Data store which retrieves an entity's attribute values when they occur in longer string; i.e, instead of seeking instances where attribute value contains a (shorter) string : request.predicate = [NSPredicate predicateWithFormat:@"carBrand contains[c] 'merced'"] I want to find instances (of the entity) whose attribute values are found 'contained in' an arbitrary (longer) string : NSString* textString = @"Elaine used to drive Audis, but now owns a

Phone No validation with regular expression - Ph. Format (974) 041-0475 [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-11 10:52:58
问题 This question already has answers here : A comprehensive regex for phone number validation (41 answers) Closed 6 years ago . I have to validate a phone number which is in following format (974) 041-0475 I have tried with regex @"^+(?:[0-9] ?){6,14}[0-9]$" but its not working for above example. It's working for plain digits. 回答1: US Phone Number Validation NSString *unformatted = textField.text;//pass textfield object with text property NSArray *stringComponents = [NSArray arrayWithObjects:

NSPredicate SUBQUERY results in: [NSMutableSet unionSet] set argument is not an NSSet

a 夏天 提交于 2019-12-11 10:02:02
问题 On an array of Artists I am trying to do filteredArrayUsingPredicate using the below format to only remain with Artists that have at least one Album that has at least one Intro song. albums is a to many relationship from Artist to Album. intros is a to many relationship from Album to Intro. I get an exception saying [NSMutableSet unionSet:]: set argument is not an NSSet . What am I doing wrong? Here is the aforementioned predicate format: @"SUBQUERY(albums, $alb, ANY $alb.intros != NULL).

iOS NSPredicate not working?

☆樱花仙子☆ 提交于 2019-12-11 09:53:07
问题 I have a simple predicate function that follows as: [totalSentences addObjectsFromArray:[firstLangEx filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains[c] %@)", cellText]]]; This line works in one of my apps, however it does not work when I copied this into another app and tried testing this. totalSentences is a global NSMutableArray firstLangEx is a local NSArray filled with several lines cellText is NSString *cellText = cell.textLabel.text; All these codes exist

Facing difficulty in parsing google location response

左心房为你撑大大i 提交于 2019-12-11 09:44:28
问题 Using iOS 8.0. I am using Google API for getting the location.and I want to reduce the coding using NSPredicate and KeyPath. I am using below link for getting the google response, iPhone - Get City name from Latitude and Longtiude Using answer of user @' Constantin Saulenco '. If I would a Sql developer I would write a query like, 1. (select address_components from MAIN_TABLE where types like 'postal_code') from this I will get NAME_TABLE rows. 2.select long_name from NAME_TABLE where types

How to filter a NSArray of subviews by tag using NSPredicate?

本小妞迷上赌 提交于 2019-12-11 09:17:37
问题 I have this array of subViews: <UIButton: 0xa2b1600; frame = (41 20; 42 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0xa2b06e0>>, <UIButton: 0xa2b1290; frame = (121 694; 69 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0xa2b0dc0>>, <SequenceViews: 0xb16fba0; frame = (62 393; 280 323); tag = 100; gestureRecognizers = <NSArray: 0xb16dc90>; animations = { position=<CASpringAnimation: 0xb16c990>; }; layer = <CALayer: 0xb168880>>, <SequenceViews: 0xb171c30; frame = (62 52; 280

Predicate works for array but not for fetchRequest

戏子无情 提交于 2019-12-11 08:28:33
问题 I am trying to create a fetchRequest that shows me all values that are not already in another array. This code returns the array I expect: NSArray *questionChoices = [self.currentQuestionChoiceGroup.questionChoices allObjects]; NSArray *filteredQuestionChoices = [questionChoices filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NONE %@ == code", myarr]]; myarr contains 1 item, and that 1 item is excluded from the filtered results, as expected. However, this code doesn't work:

Why doesn't this NSPredicate work?

孤者浪人 提交于 2019-12-11 06:13:08
问题 I have an Array of MKAnnotation objects called arrAnnotations . I want to pick out one of the annotations with the same coordinate as the one stored in a CLLocation object called "newLocation". I'm trying to use a NSPredicate , but it doesn't work. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF.coordinate == %f)", newLocation.coordinate]; NSArray* filteredArray = [arrAnnotations filteredArrayUsingPredicate:predicate]; [self.mapView selectAnnotation:[filteredArray

NSPredicate and CoreData?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 05:41:49
问题 The query works fine if directly added to a predicate NSPredicate *predicate = [NSPredicate predicateWithFormat:@"author == %@", author]; [request setPredicate:predicate]; [self.managedObjectContext executeFetchRequest:request error:nil]; The query doesn't work if created and then passed to a predicate Is there a solution? I rather not pass the predicate itself to the method Author is a subclass of NSManagedObject *** Terminating app due to uncaught exception 'NSInvalidArgumentException',

Searching files - Objective-C

為{幸葍}努か 提交于 2019-12-11 05:29:47
问题 I am trying to search for a file. This returns 0 results. Does anyone know why? NSMetadataQuery *q = [[NSMetadataQuery alloc] init]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"kMDItemFSName == %@", @"test123456.png"]; [q setPredicate:predicate]; [q startQuery]; while ([q isGathering]) { NSLog(@"%lu", [q resultCount]); } [q stopQuery]; update NSMetadataQuery *q = [[NSMetadataQuery alloc] init]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"kMDItemFSName == %@", @