nspredicate

How To Extract Information from NSArray Generated from Core Data NSPredicate?

Hi, I am using Core Data to develop an application, and I have used a NSPredicate to 'query' an entity which returns an NSArray of results, as is standard. The NSArray contains objects of 'EntityA' which itself contains attributes 'AttributeA' and 'AttributeB'. My question is, how can I extract information from this array? Furthermor...

Help with CoreData making a NSPredicate - Recursive Searching.

I am using CoreData for an iPhone project and I am stuck trying to build a predicate. My core data entity is Folder parent - Point to the folder class parent, can be null and is one to one. secure - An enum that holds the security type. The problem I have is that I am trying to make it so I don't show any folder that are ...

Fetched Results Controller with NSPredicate vs. Core Data NSSet

Okay, so I have a UITableView hierarchy. The top level controller is for Categories, which are selected via Fetched Results Controller with no predicate for the Category Entity. When a user taps a cell, they are advanced to the Items Table View Controller. At this point, I assumed I should use another fetched results controller with an...

NSPredicate string matching against NSSet's

I'm trying to use an NSPredicate to search for string matches against an array of CoreData objects generated like so: // Grab an array of all Company projects NSArray *array = [[company projects] allObjects]; I use the following predicate to match any project names, company names or client names with a case-insensitive string (note: t...

nssearchfield predictate doesnt return items with spaces

ANY contains $value.lowercaseString above is the value I place into my xib's bindings search predicate. if I type in a word such as => happy it returns correctly if I type in a word such as => happy luck then my view no longer will contain the a result. even though happy luck does exist as a searchable data point. All in all it ...

NSPredicate filter the data via relationship rather than a property

Here is my question. I have this model one [Event] has multiple [Day] and there is a relationship called days in [Event] and there is a reverse relationship event in [Day]. Now I want pass the Event object and get all days using NSFetchedResultsController and feed all days in the table. Here is my code: // Create the fetch request for ...

NSCompoundPredicate fails to match

I'm building a NSPredicate using the code below for an iPhone app. The logging shows the prediate to be: location CONTAINS "head" AND shape CONTAINS "oval" AND texture CONTAINS "bumpy" AND colour CONTAINS "red" I get no results. If I limit the predicate to a single item it will work, more than 1 fails. Can anyone tell me why? Many tha...

NSPredicate - filtering values based on a BOOLEAN stored value

I have a core data model object called Entry. In this I have an attribute IsFavorite. I would like to use an NSPredicate to filter the results of my NSFetchedResultsController. Currently I am getting EXC_BAD_ACCESS when the fetch executes. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropr...

NSFetchResultsController + sectionNameKeyPath + section order

I have a one to many entity relationship between two entities: EntityP (Parent) <-->> EntityC (Child) Attributes and Relationships: EntityP.title EntityP.dateTimeStamp EntityP.PtoC (relationship) EntityC.title EntityC.dateTimeStamp EntityC.CtoP (relationship) // Can be used to get "one" EntityP record I use fetch results controlle...

NSPredicate strings greater comparision

Hi, I am trying to compare if one NSString is "greater" than other NSString and I am stuck. Actually, my NSString contains a date and want to get all these objects that are greater than it. I know I should convert it to date, but I want to keep it as NSString. Thank You! ...

How to improve Core Data performance?

My app has a UISearchBar allowing user to enter search keywords. Each keystroke executes a Core Data query in order to display the results as text in search bar changes. The problem is that search bar keystrokes are lagging pretty bad... surely because of slow fetching. Any ideas how to improve the performance? My Core Data is backed w...

how to ask an array if an object is contained?

how can i ask an array if it contains an item and if it does it to [[NSArray alloc] initWithObjects:@"those objects" automatically. this is my fav .h @interface FavoriteViewController : UITableViewController { NSMutableArray *favoritesArray; NSMutableArray *didContain; } @property (nonatomic, retain) NSMutableArray *favoritesArr...

[iPhone dev] NSPredicate with NSDate and repeats (like Calendar app)

Hi, I have an entity "Event" witch contains two properties: date (NSDate) and repeat (NSInteger - 0 = NONE, 1 = DAILY, 2 = WEEKLY, 3 = MONTHLY, ...). Does anyone knows how can I filter events by repeats passing a date ? Example: First event: 01-01-2010 / weekly Second event: 10-02-2010 / monthly Current date: 10-06-2010 Re...

NSPredicate - returning ever unique instance in a column.

I was wondering if there was a predicate to return every unique instance in a column. ...

How do I create the right NSPredicate for this kind of request?

Hi the problem goes like this: I have in CoreData entities that have a title and a relationship to keywords entities. I need a predicate that helps me to fetch all those entities whose title contains the keywords I type. I have the code below that should do this but it doesn't: NSArray *keywords = [searchString componentsSeparatedByS...

NSPredicate with functions or selectors

I have a lot of people NSManagedObjects that I need filtering and was hoping to do it within the initial fetch instead of filtering the array afterwards. I've used selectors in predicates before, but never when fetching NSManagedObjects, for example I have all my employees and then i use this predicate on the NSArray... [NSPredicate pre...

NSPredicate syntax question

is the syntax for the line of code below correct? NSPredicate *predicate = [NSPredicate predicateWithFormat:@"type == %@",selectedAnimalType]; I want the 'selectedAnimalType' string to be used in a search to display the the user selected. I ran an NSLog statement for the %@ object and it returned what I wanted NSLog(@"%@",selectedAn...

How to find beginswith word in a string using NSPredicate?

Hello! I am searching for a solution on how to format NSPredicate to search correct word in a string of text. Currently I am using this code: NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(content CONTAINS[c] %@)", word]; but it returns wrong resuls if the word is short, for example: if the wo...

How do I use NSPredicate and a Fetch request to return an Array of entities where one Attribute contains a specific string?

I recently adapted my iPhone Application to use core data; after some research I have found that NSPredicate seems like the best way to handle my database queries. In particular, my queries will be based on 4 separate attributes. First, I need to query the database for all entities that have a specific county name. If I search for all en...

NSPredicate for an NSManagedObject's string attribute's length

Could someone please help me define a predicate that returns only NSManagedObject's who's "letters" attribute length is within a certain range? Here's the example I've been trying, I've got a feeling it's the letters.length notation, I've also tried the kvc letters.@length with no success.. What am I doing wrong? NSManagedObjectContext...