core-data

Core data, file downloads, and thread-safety

What's the preferred approach for constantly sharing data across threads when using Core Data? I am downloading a large file and want to show progress of the download in a UIProgressBar. The actual download is happening in a background thread created by NSOperation. The download information (local path, total bytes, bytes received) is ...

Embedding a predefined SQLITE doc in Core Data Application

Thanks for the help. I have a woking Core Data doc based app. that solely supports SQLITE docs. I would like to distribute the application with a previously created database document with predefined data embedded in the application bundle. How do I instruct the application to run the embedded file at runtime? thanks. -paul. ...

Xcode 3.2.1 - Why are Core Data generated Classes resulting in Build errors?

It looks like the recent Xcode 3.2 has added some code generation niceties that (I think) were lacking pre-Snow Leopard. I took the following steps: Define a simple .xcdatamodel model with a few entities, including one (inversible) one:many relationship (an Endpoint has many Subscription objects) File -> New and select the (icon-less)...

loading Core Data

Hi there, I saw your post at: http://stackoverflow.com/questions/928177/provide-base-data-for-core-data-application I'd like to follow your steps to load Core Data, preferably from a csv or something. I don't have my data in an sql database yet. if you have time, can you help? thanks! asUwish ...

Clear all the data in a particular Pesistencestore.

I use two PersistenceStores one for saving phone setting related entities and Other for saving User details related entities. I need to clear all the User details related entity on log off , so i delete the userdetails.sqlite using [NSFileManager removeItemAtPath: error:] method. After this i setup the managedobjectcontext but i am not...

Illegal attempt to establish a relationship 'xyz' between objects in different contexts

I am using Apple's CoreDataBooks sample application as a basis for pulling data into a secondary managed object context in the background, and then merging that data into the primary managed object context. The data I am pulling in is a Book entity with a to-one relationship with an Owner entity (called "owner"). The Owner entity has a ...

Cocoa-Touch, NSManagedObject: Exception when setting a property.

I have a NSManagedObject subclass, created by the XCode model interface. This class has some NSString and NSNumber members, and a NSDate member. When I try to set the NSDate member, I get the following exception: 2009-10-12 21:53:32.228 xxx[2435:20b] Failed to call designated initializer on NSManagedObject class 'Item' 2009-10-12 21:53:...

I think I lost my Managed Object Context

So I'm working on a clone of CoreDataBooks. It's a little different. When the '+' button is pushed, it launches a navController, containing 2 views. The first (AddPatientVC) asks for name of the Patient then its pushed to a 2nd View Controller (AddPatientDetailVC) which asks for more detailed information. It's the 2nd view controller th...

Core Data Migration Across Multiple Version Upgrades

I have an iPhone app that uses Core Data. I did an update and used Lightweight Migration to go from V1 to V2 of my MOM (Managed Object Model). This worked perfectly. What happens when I want to go to V3 (and beyond) of my MOM? If I decide to continue with Lightweight Migration, will it automatically deal with migrating from V1 to V3...

Saving video from UIImagePickerController to Core Data on iPhone OS

I need some guidance on how to save video data to core data so that I can retrieve it again later. I have no problem retrieving the NSURL that is returned from UIImagePickerController but then I'm not sure how to go about saving the video data to Core Data. I can already save and retrieve regular images from Core Data but I'm not sure h...

How do you handle section inserts with an NSFetchedResultsController?

I've got an NSFetchedResultsController as my data source and and I implement NSFetchedResultsControllerDelegate in my custom UITableViewController. I'm using sectionNameKeyPath to break my result set into multiple sections. In one of my methods, I'm adding a couple of objects to the context, all of which are in a new section. At the m...

Validation Errors with Core Data Migration

I'm encountering a very annoying error using Core Data on Mac OS X 10.5. All entities have classes in my application which share the same names. Up to this point, I've done 5 migrations without problems. I'm using the XML data store. I've got V5 of my data model with 13 entities, 4 of which are abstract. It looks like this: What I d...

Best practice? - Array/Dictionary as a Core Data Entity Attribute

I am new to Core Data. I have noticed that collection types are not available as attribute types and would like to know what the most efficient way is of storing array/dictionary type data as an attribute (e.g. the elements that make up an address like street, city, etc. does not require a separate entity and is more conveniently stored ...

Queue of NSOperations and handling application exit

Hi there, I'm about to create a series of NSOperations and run them in a queue. They will all be sequential and run one at a time. These operations will fetch data from the web and create and save core data managed objects. How do I handle the situation where the application exits? As the operations run in detached threads, how can I...

How do I call NSManaged object's @dynamic method from from another object using a @selector and NSInvocation?

Cocoa newbie here. I am working on an iPhone UITableViewController-based widget that can be used to edit date and text properties in an object set during initiation. Currently, I am attempting to do this with a @selector and NSInvocation as below. Note: the "targetObject" is the object set when the controller is initialized. - (IBAct...

CoreDataBooks Add new cell to tableview

Hi, I recently downloaded Apple's sample app CoreDataBooks and for the sake of learning decided to add a cell to the last record in the RootViewController.m table view, which would display the number of records that were fetched. The code I added is shown below. I didn't get to the point of adding the fetch count because I am getting b...

disordered/ordered context fetching

Hello to everyone, I cannot understanding why values assign to array objects become "disordered" after executing executeFetchRequest. Well, I'm not certain that fetching is the problem here. Here's the code. objects=[NSArray arrayWithObjects:@"a",@"b",@"c",@"d",@"e",nil]; NSManagedObject *DB = nil; for (int i=0;i<[objects count];i+...

How do I make an exact duplicate of a Core Data object graph?

I need to make a duplicate of an existing object graph from one NSManagedObjectContext and insert it into a second NSManagedObjectContext. Is there a straightforward way to do this? From what I can tell I could ask the MOC for its -registeredObjects and then do something like this to copy the attributes: NSString* entityName = [[...

Core Data returns NSManagedObject instead of Concrete class, but only when using . accessor

I have set up a Core Data model where I have two objects, say Person and Address. A person has an address, and an address can belong to many people. I have modelled it in core data as such (so the double arrow points to Person, while the single arrow goes to Address) I have then created two classes for those objects, and implemented som...

How can you reference child entity name in a predicate for a fetch request of the parent entity?

I have the need to create a complex predicate for an abstract base object. I want to have separate predicate queries for different inheriting entities and key off the sub-entity type, the example below is what I would like to do, however, I have not been able to find a way to reference the entity name or type in the predicate. NSFetchR...