core-data

Core Data cannot resolve faults when object has "description" attribute?

EDIT: see below for a fix, but I don't understand why the fix works. :) Code: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"A" inManagedObjectContext:moc]; [fetchRequest setEntity:entity]; NSSortDescriptor *sor...

Do I need to update the table view manually after calling performFetch in a Core Data app?

I'm new to this Core Data business. I got a UITableViewController hooked up with a NSFetchedResultsController. In viewDidLoad, I fire a request to get necessary data from the server, then use [self.fetchedResultsController performFetch:&error] to update the table view. All works fine until that point. Now I want to move the data fetchi...

Making a copy of a NSManagedObject which isn't managed.

So my problem is that I have a NSManagedObject 'A' which has a has-many relationship to 'b'. So for each object of 'A', there can be many 'b'. Now, I want to make a copy of 'b', so that 'b' can be modified, but not saved to the store, but 'A' can be saved'. For example, self.title = A.name; setOfB = A.setOfb; // This is still managed...

[self.managedObjectContext deleteObject:self];

[self.managedObjectContext deleteObject:self]; Is there a problem, conceptually, with executing this line of code? ...

Core Data and Core Location

I have a Core Data database with latitude and longitude properties. Is there a way to use Core Location's getDistanceFrom: method to find the five nearest locations to a CLLocation obtained from the GPS? Do I have to load all the objects using Core Data and parse through them, using getDistanceFrom: on each one or is there an easier way?...

Switch to use Core Data during development?

Hi, I decided to switch to use Core Data to save all the data in my navigation application. What are the steps necessary to make Core Data available in my application? I don't want to start a new project with the check box 'Use Core Data for my application' and copy all the existing codes to the new project. Anybody has any guides or ...

Add Core Data Index to certain Attributes via migration

For performance reasons, i want to set the Indexed Attribute to some of my entities. I created a new core data model version to perform the changes. Core Data detects the changes and migrates my model to the new version, however, NO INDEXES ARE GENERATED. If I recreate the database from scratch, the indexes are there. I checked with SQ...

Core Data and threading

What are some of the obscure pitfalls of using Core Data and threads? I've read much of the documentation, and so far I've come across the following either in the docs or through painful experience: Use a new NSManagedObjectContext for each thread, but a single NSPersistentStoreCoordinator is enough for the whole app. Before sending an...

Thread-safe unique entity instance in Core Data

I have a Message entity that has a messageID property. I'd like to ensure that there's only ever one instance of a Message entity with a given messageID. In SQL, I'd just add a unique constraint to the messageID column, but I don't know how to do this with Core Data. I don't believe it can be done in the data model itself, so how do you ...

How to implement delayed/batched table view update from NSFetchedResultsControllerDelegate?

The documentation says: You should consider carefully whether you want to update the table view as each change is made. If a large number of modifications are made simultaneously—for example, if you are reading data from a background thread— /.../ you could just implement controllerDidChangeContent: (which is sent to the delegate whe...

One NSFetchedResultsController vs several UITableViews — only one UITableView gets updates?

Setup: I have several UITableViewControllers (tvc) that all instantiate a separate NSFetchedResultsController (frc). All these frc-s, though, use the same ManagedObjectContext (moc). Scenario: Sometimes, from one of the tvc-s, I launch some background process to update data. The background process updates the data in a separate thread...

NSFetchedResultsController with predicate based on dependent property

I have a Core Data iPhone app that displays Subscription entities where any of its items are not read. In other words, I construct a predicate like this: [NSPredicate predicateWithFormat:@"ANY items.read == NO"] While this works for the initial fetch, it doesn't affect Subscription entities when I modify an Item, so the NSFetchedResul...

iPhone Core Data: Do Transformable Attributes have to Transform to only Data?

I've been using transformable attributes in core data to transform complex objects like images and colors into raw data. I took this... The idea behind transformable attributes is that you access an attribute as a non-standard type, but behind the scenes Core Data uses an instance of NSValueTransformer to convert the attrib...

Core Data Crashing during NSManagedObjectContext processPendingChanges

I am getting a (what seems to me as a strange) crash with Core Data. From what I can gather it is happening when Core Data does a save and subsequent managedObjectContextDidSave methods are fired. I am at a loss and really hoping someone can help me out or guide me in the right direction. The crash report is as follows: Exception Type...

Core Data Saves and UI Performance

I'm wondering if there are any best practices for improving UI responsiveness while doing Core Data saves (not fetches) with large collections of managed objects. The app I'm working on needs to download fairly large amounts of data on set intervals from a web service until complete. On each interval, a batch of data is downloaded, f...

How to remove deletedObjects from ManagedObjectContext?

Hi, I have two enities: path <-->>> node. (one to many) In nodes ArrayController I override -DeleteObjects: to remove path if the last node is removed. Everything works perfect, but it's impossible to save edited document, because nodes are left in [ManagedObjectContext deletedObjcets]. It gives error on save. How to clean them up? Bab...

Using CoreData with an object?

Hi there, this is a beginner's question: Every tutorial I've seen on CoreData focusses on database-backed storage. They all start out with drawing an object model with relationships and whatnot. But my app will be like a simple drawing app, think Illustrator light or OmniGraffle. I have an object in memory for the page and then severa...

CoreData weird behavior when data are loaded on background thread

Hi there, I have very strange problem, when I don't understand what's going on at all, so I'm looking for explanation of it. Situation is as following: I have a view controller with scrollview with three subviews in it. Those three subviews have method -(void)loadContent which loads content from database using CoreData in the backg...

Does Core Data cache transient attributes?

I have the following scenario: entity with a transient attribute used for sectioning web-based data model periodically refreshed NSFetchedResultsController Everything works fine, but when I do a refresh, that transient attribute seems to be getting out of date. The attribute is returned by an accesssor in my entity object. I tried s...

How to use NSFetchedResultsController and UISearchDisplayController

Hey! I've been creating an iPhone App using Core Data. First of all, does it make sense to use an NSFetchedResultsController and a UISearchDisplayController together to fetch the result? Would you recommend something else? I've been trying quite long combining an NSFetchedResultController and a UISearchDisplayController. I've been thi...