core-data

Reset a CoreData persistent store

Hi everybody, Basically, what I'm trying to do is to wipe out all data in my CoreData persistent store, then import new data. How would you do this? It seems that the simplest solution is call [NSPersistentStoreCoordinator removePersistentStore:error:] and then remove the file. Is that the best practice available? Is it thread-safe? Th...

How to update data in a different ViewController and show it in the parent ?

Hi all, I asked a similar question a while back, but I'm clearly missing something. I have 2 view controllers - one that displays the data and one where data is edited. In my first controller, I create my object: thing = [NSEntityDescription insertNewObjectForEntityForName:@"Thing" inManagedObjectContext:managedObjectContext]; thing....

Using mergedModelFromBundles: and versioning (CoreData)

Hi everybody, I'm trying to use the migration feature in CoreData. I've followed the Apple Documentation. I have a problem in the following method: /** Returns the managed object model for the application. If the model doesn't already exist, it is created by merging all of the models found in the application bundle. */ - (NSManagedO...

NSOutlineView Sidebar help

I'm trying to create a simple sidebar using NSOutlineView..... how would I do this? (I'm using CoreData) ...

Core Data VS SQL Statement, which one is gd for iphone development?

iPhone 3.0 support the Core Data, it seems a great tool for developer. But SQL statement seems it is easier to get start, but core data is easier for maintaining db. But I'm considering the SQL statement, because it seems have better performance. I am consider which one is better for iPhone development, any suggestion? ...

How can I keep multiple NSManagedContext's in sync?

I've spent a couple of hours tonight trying to create a setup whereby I have three managed object contexts - one attached to my application's delegate, one in an NSObject subclass responsible for UITableView updates (via an NSFetchedResultsController) and one in an NSOperation subclass. I can get the changes from the NSOperation subclas...

How do you export/import image data like Apple's Contacts app?

I have an core data app that stores strings and a couple of images. I would like users to be able to send entries to each other via email (like Apple's Contacts app). I have created a url scheme that exports/imports all the strings, but the image data is a tough one. Any help or point in the right direction would be greatly appreciate...

What steps should be taken to convert my XML into Core Data objects?

Hi all, I have an XML file which contains lists of stores, a simplified version is below. What I would like help with is some high-level ideas on the simplest ways to move this data into objects for storage in Core Data. I see suggestions around key-value pairs but as you can see in my example below, I have child elements with the same...

Core Data - Associate a Quantity to a Relationship

I have a Core Data entity called "Item" and it represents an item in a store so it has a name, price, and a few other attributes. I would like to be able to create lists of these items and I am having some trouble figuring out how to do it. The problem is that I need to be able to associate a quantity for each item in the list AND I n...

Core Data vs. SQLitePersistentObjects

I'm creating an iPhone app and I'm trying to choose between 2 solutions for a persistent store. Core Data, or SQLitePersistentObjects. Basically, all my app needs is a way to store an array of model objects and then load them again to display in a UITableView. Its nothing too complicated. Core Data seems to have a much higher learning c...

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

iPhone database migration times out

I have an iphone app that allows you to download map tiles, which are stored in a core-data sqlite database. I'd previously set up database migration using momd, following this guide - http://iphonedevelopment.blogspot.com/2009/09/core-data-migration-problems.html That all works perfect when testing upgrading, when I have small amounts ...

Disable persistence of a given NSManagedObject until user hits a button?

I have an NSManagedObject with attributes that a user can edit with a view. The view is populated with the values from the object, the user can edit the values, and the values are written back to the object. I want the user to explicitly tap a save or cancel button to commit or undo the changes. The problem is that the view is in a UI...

Having difficulty debugging a iPhone Core Data bug

I'm hoping someone can help me debugging an incredibly frustrating Core Data crash. I initially load data into two entities (representing 'speakers' and 'titles') I then load a third entity for 'sessions' and try to set relationships to 'speakers' and 'titles'. (from session to speaker and title is one-to-one. from speaker/title back...

Core Data data model: attribute type for UIColor

I'm just starting out with Core Data and right now I'm building my data model. I need a UIColor attribute for my entity, but the type dropdown for the attribute doesn't have an option for this. Do I set it to Undefined or what? Thanks ...

Multiple NSFetchedResultControllers for different entities?

I'm checking out the default Xcode template for an iPhone Core Data project. In the method that returns the fetched result controller I see this: - (NSFetchedResultsController *)fetchedResultsController { ... NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForN...

How do I give my parsing code access to my ManagedObjectContext?

I'm writing an iPhone app which fetches an XML file, parses it and then saves the parsed objects to Core Data. I've got everything working up to the point where I save the objects to Core Data. I imagine it's got something to do with how I'm referencing the ManagedObjectContext but I can't figure out where I'm going wrong. I've looked...

Core Data: UITableView with multiple NSFetchedResultControllers

What I want to do is pretty simple. In my UITableViewController, I want to load data from multiple NSFetchedResultControllers (I have multiple entities in my data model) and put data from each one into a different section in the table view. So for example, all the fetched items from the first NSFetchedResultController would go in section...

Implementation of "Automatic Lightweight Migration" for Core Data (iPhone)

Hi I would like to make my app able to do an automatic lightweight migration when I add new attributes to my core data model. In the guide from Apple this is the only info on the subject I could find: Automatic Lightweight Migration To request automatic lightweight migration, you set appropriate flags in the options dicti...

Managed object context deleting then saving objects raises objc_exception_throw error

Hi, I have the following error while trying to call the save method on managedObjectContext. #0 0x939214e6 in objc_exception_throw #1 0x01ded83b in -[NSObject doesNotRecognizeSelector:] #2 0x01d84676 in ___forwarding___ #3 0x01d606c2 in __forwarding_prep_0___ #4 0x01c618b6 in -[NSFetchedResultsController(PrivateMethods) _managedOb...