Questions tagged [predicatewithformat]
13 questions
4
votes
1 answer
How to check if an objects is inside of a NSSet of objects by using predicateWithFormat in CoreData?
In my iPhone app, I try to have a TableViewController to display a list of photos those share one same tag (currentTag in code below). Photo and tag are "many to many" relationship in database. Each photo has an attribute named "tags", which type is…

WHT
- 63
- 1
- 7
2
votes
1 answer
Filtering objects from array by a property, using the method filteredArrayUsingPredicate
I can't understand how to use predicate, I have a very long code to filter objects from array by property "type" and suddenly I saw method "filteredArrayUsingPredicate" that can make my life better. I try write predicates but I always get errors;…

Dennis
- 704
- 1
- 9
- 25
1
vote
2 answers
+[NSPredicate predicateWithFormat] substitute reserved words
Is it possible to substitute reserved words, specifically OR and AND, into a predicateFormat?
I tried:
NSString *andOr = (isAnd ? @"AND" : @"OR"); // isAnd is a BOOL variable
NSPredicate *predicate = [NSPredicate predicateWithFormat:
…

ma11hew28
- 121,420
- 116
- 450
- 651
1
vote
1 answer
NSPredicate - predicateWithFormat insecure
I have a predicate for query in core data base but i don't know what is the correct way to validate its params?
- (void) queryToDatabaseWithStoreId:(NSInteger) storeId {
[NSPredicate predicateWithFormat:@"store.storeId = %d", storeId];
}
My…

jordiz
- 279
- 3
- 8
1
vote
2 answers
Using NSPredicate to filter NSArray by keywords
I have an NSArray called myArray. I want to filter myArray objects so, that I exclude all elements from this array corresponding to the keywords from another array keywords.
So, that's my pseudocode:
keywords = @[@"one", @"three"];
myArray =…

Artem E.
- 23
- 5
1
vote
2 answers
NSPredicate predicateWithFormat for email issue
I am facing issue to create NSPredicate type object with predicateWithFormat method.
AppDelegate *appdelegateObj = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.managedObjectContext = [appdelegateObj…

PK86
- 1,218
- 2
- 14
- 25
1
vote
1 answer
iOS - Help Using [NSPredicate predicateWithFormat]
Hey so I'm using a NSPredicate to filter an array. Currently I use the following piece of code:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.name contains[c] %@", searchText];
This has been working alright as it looks for the…

ScottOBot
- 839
- 3
- 16
- 37
1
vote
1 answer
NSPredicate use with Array with multiple objects
I have an app that correctly uses NSPredicate to filter an array and displays the resulting filtered array to the user.
Here is my NSPredicate code:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(Name CONTAINS[cd] %@) OR (Acronym…

VonKoob
- 77
- 1
- 9
0
votes
1 answer
NSPredicate to check for NULL, and blank strings in Core Data
As CoreData length is not supported and CoreData translates the predicate name.length > 1 to sqlite in name > 1... While it should be length(name) > 1.
We can use this one:
[NSPredicate predicateWithFormat:@"NOT name MATCHES '^\s*$'"];
But…

Umair Suraj
- 480
- 11
- 22
0
votes
2 answers
predicate is getting nil, nscoredata, objective
What I am doing to fetch the data for core data is following
NSString *str;
NSPredicate *predicate;
switch (typeCube) {
case NewCubes: {
str = [NSString stringWithFormat:@"type == %d",NewCubes];
break;
}
case AllCubes:…

tranvutuan
- 6,089
- 8
- 47
- 83
0
votes
1 answer
predicateWithFormat:argumentArray: Using all items in NSArray
- (void)filterViaCategories:(NSArray *)array {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(todo_category_id == %@)" argumentArray:array];
}
but when I have used:
po predicate
Result is:
todo_category_id == 41123..
It…

Umair Suraj
- 480
- 11
- 22
0
votes
1 answer
NSPredicate checking certain String
I m working on a code which was implemented by someone else which is as follows
+(BOOL)emailValidate:(NSString *)email {
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate…

AsifHabib
- 944
- 9
- 25
0
votes
1 answer
NSPredicate predicateWithFormat: still counting previously deleted data
I am displaying several tasks of a list of activities. To achieve this I am using NSPredicate predicateWithFormat: to select the items of the list. But the problem I have is regarding previously deleted tasks of that list. Even though they are not…

Armand
- 435
- 1
- 11
- 23