nspredicate

iPhone, Core Data, Predicate with "self" problem.

Hi there, I need to reload a Person NSManagedObject before I pass it onto the next View. This is because the fetchedResultsController I'm using is only returning a subset of attributes and I need the full set in the next view. Thus far I'm trying something like: - (void)tableView:(UITableView *)tableViewPassed didSelectRowAtIndexPath...

Are predicate templates the same thing like prepared statements?

For example if I had this predicate format string, would that have the same security benefits like prepared statements in SQL offer? @"name == $LAST_NAME" I am not sure if this is a plain stupid substitution which still allows bad "SQL" injection to core data, or if this is just as good as prepared statements known from modern db tech...

An NSPredicate that can recursively traverse an object graph?

I'm trying to filter an array of objects that essentially form a tree-style graph. what i want to do is to filter out all objects from this array whose visible property is NO, or if its parent/grandparent/etc visible property is true (child objects can have the visible property be YES while its parent can be NO). I'm unclear as to ho...

Debugging Core Data managed objects with predicates

My application has the data models a little bit complicated. I need to debug a fetch request with different predicates. Is there any fast way to see different results for different predicates? I am tired with changing only one predicate and I have to start again my navigation application with nearly 10 steps before. An example of these...

Core data to-many NSPredicate with AND

I'm trying to write a query for the find-as-you-type search bar. What I want to do is query "Kind", and return any Kinds for which there is a LocalName with ('name' LIKE %@ AND localeIdentifier == %@). If I'm only searching the names (so ignoring the localeIdentifier), I could do something like this: ANY localized.name LIKE %@ What...

NSPredicate as a constraint solver?

I'm working on a project which includes some slightly more complex dynamic layout of interface elements than what I'm used to. I always feel stupid writing complex code that checks if so-and-so is close to such-and-such and in that case move it x% in some direction, etc. That's just not how programming should be done. Programming should ...

Getting Core Data Entity from a Parent Entity

I'm trying to retrieve data from an Entity in Core Data where I know the value of a related Entity. IE: Entity1 -attrib1.1 -attrib1.2 -relationship1 Entity2 -attrib2.1 -relationship1 Entity1 has a to-many relationship to Entity2 on relationship1. I'm trying to get the value of Entity2 where Entity1.attrib1.1 = XXX. I tried using NSP...

How to use NSPredicate to catch child objects?

I'm new to core data and try to get all children objects of various types with one query. Say there's an "Animal" type as parent and "Cat", "Dog" and "Bird" as children. I'd like to get both cats and dogs, but not Birds in single query returned as Animal objects. Is it possible? ...

Core Data NSPredicate to filter results

I have a NSManagedObject that contains a bID and a pID. Within the set of NSManagedObjects, I only want a subset returned and I'm struggling to find the correct NSPredicate or way to get what I need out of Core Data. Here's my full list: bid pid 41 0 42 41 43 0 44 0 47 41 48 0 49 0 50 43 There is a paren...

NSPredicate problem with fetchedResultsController

Please help! I've been trying to figure this out for way too long. I can't seem to use an NSPredicate in my fetchedResultsController method: - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) return fetchedResultsController; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; ...

NSPredicate and Regex

Can someone please help me with using Regex with NSPredicate? NSString *regex = @"(?:[A-Za-z0-9])"; NSPredicate *pred = [NSPRedicate predicateWithFormat:@"SELF MATCHES %@", regex]; if ([pred evaluateWithObject:mystring]) { //do something } testing the above wth mystring - qstring123 doesn't seem to work. I am expecting it to enter ...

NSPredicate of special characters - iPhone

Hi everyone, I'm trying to make a predicate that includes special characters For example: [[myIngredients filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"name BEGINSWITH[c] %@", [alphabet objectAtIndex:idx]]]; Here I will get all the ingredient which starts with (let say for idx = 5) 'e'. As I have to do my app in englis...

NSFetchedResultsController: changing predicate not working?

Hi, I'm writing an app with two tables on one screen. The left table is a list of folders and the right table shows a list of files. When tapped on a row on the left, the right table will display the files belonging to that folder. I'm using Core Data for storage. When the selection of folder changes, the fetch predicate of the right ta...

NSPredicate and arrays

Hello, I've got a short question. I have an NSArray filled with Cars (inherits from NSObject) Car has the @property NSString *engine (also regarded @synthesize ...) Now I want tu filter the array using NSPredicate predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"(engine like %@)", searchText]]; newArray = [Arra...

Problem with the name of an NSEntityDescription

This problem follows on from a previous question. When I run the following line of code: NSEntityDescription *outputCellEntityDescription = [NSEntityDescription entityForName:@"OutputCell" inManagedObjectContext:[[self document] managedObjectContext]]; I get the followin...

Core Data - NSPredicate to filter to-many relationship

I have 2 entities, Task and List. Each task has a to-one relationship to a List object called "list", and there is an inverse relationship with List, which has a to-many relationship with Task called "tasks". I'm trying to use a fetch request with an NSPredicate to get all the Task objects that belong to a specified List: NSPredicate ...

Is it possible to filter an NSArray by class?

Is there a way construct a predicate to filter by class type? I currently loop through the array and check to the class of each object. Maybe there is a cleaner way? ...

iphone, get the object count without performing a fetch?

Hi, I seem to recall that it's possible to return the resulting object count from an NSPredicate in CoreData without actually performing a fetch, but I can't find any reference to this. Can someone confirm that I wasn't dreaming (sad dream to have!), and would this be safe to do in another thread? Thanks Andy ...

CoreData many-to-many relationship NSPredicate Exceptions

I'm trying to model a Person/Team relationship. It's a many to many relationship since a person can belong to multiple teams and a team can have multiple people. As suggested by the doc I created an intermediate entity called TeamMember. I am now trying to run a query to see if I have a list of people, whether a pre-existing Team already...

NSPredicate acting strange in NSFetchedResultsController

I feel as if this should be very simple, but it's behaving strangely. I have 3 entities, with a relationship as such Entity A <-->> Entity B <<--> Entity C I have an NSFetchedResults controller and I'm trying to filter the results of Entity A using the following predicate. [NSPredicate predicateWithFormat:@"NONE entityB.entityC == %@...