nsfetchrequest

Different results from array controller and fetch request for relationship with nil value

I'm using a simple NSComparisonPredicate similar to: ("employeeDepartment != %@", department) where employeeDepartment is an optional, one-to-many relationship in Employees, and department is an NSManagedObject of Departments. When applied against the Employees entity, I'm getting different results from an NSArrayController vs an NSFetch...

setIncludesSubentities: in an NSFetchRequest is broken for entities across multiple persistent stores

Prior art which doesn't quite address this: http://stackoverflow.com/questions/1774359/core-data-migration-error-message-model-does-not-contain-configuration-xyz I have narrowed this down to a specific issue. It takes a minute to set up, though; please bear with me. The gist of the issue is that a persistentStoreCoordinator (apparentl...

How to fetch managed objects sorted by calculated value

Hello, I'm working on the app that uses CoreData. There is location entity that holds latitude and longitude values. I'd like to fetch those entities sorted by distance to the user's location. I tried to set sort descriptor to distance formula sqrt ((x1 - x2)^2 + (y1 - y2)^2) but it fails with exception "... keypath ... not found in ent...

iphone coredata fetch-request sorting

I'm using core data and fetching the results successfully. I've few questions regarding core data 1. When I add a record, will it be added at the end or at the start of entity. 2. I'm using following code to fetch the data. Array is being populated with all the records. But they are not in the same order as I entered records into entity....

Core Data: trying to find minimum date for an attribute in an entity

I'm trying to find the oldest date in a particular attribute in Core Data. I've found an example in the Core Data Programming Guide that purports to do exactly that, but keep getting an unrecognized selected error when I run it. My code (with only minimal changes from the Apple Example): NSFetchRequest *request = [[NSFetchRequest allo...

iPhone OS: Fetching a random entity instance using NSPredicate Nsfetchrequest and core data

Working on an app where I have a large collections of managed objects against which I want to fetch a few random instances. My question is, is there any way I can use NSPredicate and NSFetchRequest to return several objects at random. I saw that you could actually add a NSFetchRequest into the entity using the data modeler, any way to ...

Variable Substitution with FetchRequests stored in a CoreData Model

Hello, I've always created my NSFetchRequests entirely in-code. Now I'm looking at the Xcode GUI for building a fetch request and storing it in the model. I'm following an example from the Xcode Documentation. I added a Fetch Request to my model, and the predicate that has been created through the Modelling GUI is: firstName LIKE[c]...

iPhone: Get indexPath of Predicate Object

I am using a predicate to find an object in core data. I can successfully find the object that I want, but I need to also get the indexPath of that object, so that I can push a details view in for that object. Currently I have the following code for getting my object: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; ...

core data and paging

I have a database of 50,000 records. I'm using core data to fetch records from a search. A search could return 1000 records easily. What is needed to page through these records using core data and uitableview? I would like to show 100 records at a time and have 'load more' button after viewing 100 records. ...

Why CoreData crashes with "unrecognized selector" when I try to set a relationship?

I have simple tree structure in one CoreData entity called "Item". Any item can be parent of another item and can have multiple children. There's following relationships in the entity: childItems: To-Many, Destination: Item, inverse: parentItem. optional parentItem: Destination: Item, inverse: childItems. optional I am using Xcode-ge...

UITableView not updating DataSource after change to NSFetchedResultsController

I have an UITableView populated by a NSFetchedResultsController. The initial fetch works fine. I can add, remove, modify, etc with zero problems.. But I want to add user-defined sorting to the table. I am doing this by changing the NSFetchedResultsController to use a different sortDescriptor set, and a different sectionNameKeyPath. Here ...

NSFetchRequest predicate syntax

Hi, I have an entity called Task in my Core Data model. The Task entity has a transformable attribute called date. The class of the date attribute is a class called TDate (which conforms to NSCoding, therefore being a transformable attribute). TDate has a property of type NSInteger called month. In my NSFetchRequest I want to get all ...

Core Data - NSFetchRequest Problem

Hello, I have a problem with my NSFetchRequest, it doesn't seem to be fetching any data, code below: -(void)addAnnotations { NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"WayPoint" inManagedObjectContext:managedObjectContext]; [request se...

[[[NSFetchedResultsController sections] objectAtIndex:0] numberOfObjects] > fetchLimit

I am currently having an issue where my UITableViewController/UITableView which uses an NSFetchedResultsController displays about 86 items when the fetchLimit on the fetchRequest for the FRC is 4. I know that 86 items satisfy the fetch itself, and I know that the reason that they appear is because the didChangeObject: atIndexPath... get...

NSFetchRequest without sort descriptors

We cannot use NSFetchRequest without providing NSSortDescriptor(s). All i want to do is fetch the results and show them in the order in which they were created. Is there a built-in way to do that?, or will i have to create a new "auto-increment" field? (which goes against everything CoreData stands for, in my opinion). ...

Multicharacter Table Section Titles Using NSFetchRequest

Hi there, I've just started using NSFetchRequests to handle all of my table/database connections, and it was going fine until I tried to implement a table that had sections in it... The problem is that one of my tables is sectioned based on a floating point value which can take the value of: 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0,...

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...

How to cache NSFetchRequest results without NSFetchedResultsController?

Is there a way to cache NSFetchRequest results, but without using an NSFetchedResultsController? I know how to set the cache name for the results controller, but in a number of instances I just pull data from my core data store and want to cache it -- but have no need for a results controller. Any ideas on how to do this? I can't find an...

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...

iPhone Core Data get Grandchildren

If I have entities set up for Parent - Child - Grandchild and one to many relations between them I know I can then get all the Child entities for a parent or all the Grandchild Entities for a Child. Is it possible to run a fetch that will get all the Granchild entities for a given Parent? Thanks for any help! ...