core-data

Getting started with Core Data

I am having trouble understanding how Core Data works conceptually and in terms of code. I get that there is a coordinator and a context. I also get that there is state management. How do they work together? I don't understand how I can store, say, an image and a few strings as an object. Let's say I want to retrieve the image and the...

Avoiding infinite recursion synching between multiple NSManagedObjectContexts

The setup: I have two managed contexts setup (on an iPhone application). A main context that I use for most queries and a background context I use for long running operations that I want to happen in the background. I've setup notifications for NSManagedObjectContextDidSaveNotification against each managed object context. In response t...

How can I insert new objects at top of UITableView backed by Core Data/NSFetchedResultsController?

I have a tableview that is successfully incorporating an NSFetchedResultsController. However, I need the topmost cell in my tableview to read, "Add new object" and have UITableViewCellEditingStyleInsert instead of the default UITableViewCellEditingStyleDelete. The FetchResultsController wants to check the managedObjectContext for object...

CoreData Entity Inheritance

Consider that i have two entities with following relationship: Entity A <-->> Entity B (one-to-many and inverse) Now consider that i have another entity Entity C that contains all the attributes of Entity B and some others, with following relationship: Entity A <-->> Entity C (one-to-many and inverse) Now i can improve the architec...

unable to fetch related records in relationship in coredata , why ?

Hi all, I have to entities namely 'account' and 'event'. The account has to-many relation to event and inverse to-one from event. Now when I save a event object to account it is working nicely. But when I fetch for events for particular related account it gives all the entities available which is not desirable behavior. I am passin...

Best practices for core data store (sqlite) backup?

I am working on an update for my new iphone app (FlashCards++) which will include the ability to back up & restore the core data store (sqlite). I have been looking for good options for how to do this but there are very few resources about this. What are the best practices that you have found for doing core data backup? I'd like to keep ...

iPhone: NSFetchedResultsController with delegate and data update from a separate thread

Hi all! First of all, sorry for the too long question. I know that there are few questions here that discuss similar issues but none of these talks about NSFetchedResultsController with delegate together with update in separate thread. And none of the solutions has helped me. These are the existing questions: NSFetchedResultsControll...

Adding Objects to persistent store from user input

Ok, lemme start out by saying Im new to this! LOL I have done my due diligence of studying the topics (4 books and numerous videos to date) and searching for hours on end, and still havent found an answer. I feel like I have a solid understanding of Core Data, or at least the back end DB side of it. I have my app built and I have m...

Why is NSFetchedResultsController assigning fetched objects to multiple UITableView sections?

In another question of mine concerning the addition of an insert row in a UITableView backed by Core Data, I mentioned that my NSFetchedResultsController is assigning each object it fetches to a separate section in my UITableView. I assumed this was merely the default behavior, but Marcus S. Zarra said there might be something wrong with...

NSFetchedResultsController.sortDescriptor by KeyPath

Hi, How can I set my fetchedResultsController.sortDescriptors to contain a sortdescriptor that uses a keypath, for instance, such as @"foo.name"? Cheers Nik ...

Can Core Data use a Web Service as a persistence store?

Hi all, I'm working on an app that uses Core Data, and I'd like to be able to code it in a way that it can use a local SQLite store or a web-based store (with an XML or JSON response schema). Is it possible to use the exact same code for the Core Data stuff and just select the appropriate persistence store based on a user's preference?...

Core Data setReturnDistictResults Does it work on NSString * ?

[request setReturnsDistinctResults:YES]; does not return distinct results for NSString *attribute? for below example structure I have 17 managedObjects of kind Values with attribute assetGroupName and I am trying to fetch all distinct assetGroupNames value like [request setResultType:NSDictionaryResultType]; [request setReturnsDis...

NSFetchedResultsChangeDelete not being triggered

Has anyone run into this before? When I choose to delete a row from my tableView (populated by an FRC), the app doesn't crash or hang. It doesn't do anything. The delete button stays selected and if I click elsewhere on the simulator, the delete button deselects and disappears, but the cell is never removed form the UI. I'm sure there i...

Core Data - Simple Query Question

Howdy all, I am working on a simple Core Data app. I have two classes: Client and Home. There is a one-to-many relationship between Clients and Homes (i.e., a Client can have many Homes. Among other attributes, the Home class has one called purchaseDate. I am trying to write two methods on the Client class: -homesByDate and -firstHo...

Reset of CoreData works in simulator, not device (until app re-launch)

I'm trying to do a CoreData DB reset by removing a store and copying a default version in its place. The following works fine in the simulator, but when it runs on a device (testing using iOS 3.1.3 and 3.2.1) the app acts as if the database was never reset until the app is restarted. After a restart the newly initialized database is used...

CoreData doesn't fetch any rows

I have a very basic CoreData backed iPhone application. After I forced the app to generate the sqlite file, I took it and prepopulated it with one record to test loading it into tableview. I've hit a snag, though, because CoreData doesn't seem to be finding the row in the table. - (NSInteger)numberOfSectionsInTableView:(UITableView *)t...

CoreData and ASP.NET webservices.

Hi, I'm developing an iPhone app that relies heavily on calling ASP.NET Webservices to transfer data to and fro between a database in one of our servers and the phone. There are multiple items that the user works on. And to work on each item, a typical usecase requires 5-6 webservice calls. Depending on 3G signal strengths, the amount ...

Replacing Core Data sqlite file while app is running, data does not update

I am developing a backup/restore system for my app in which the user can download a backed-up version of the core data store (sqlite file) and replace the currently-used data store with the downloaded file. However, once the user downloads the file and replaces the current data store, none of the data appears to have been updated. But wh...

Core Data - How to get related records through a join table

Hello, Supposing you had a Core Data relationship such as: Book ---->> Chapter ---->> Page Given a Book object called aBook, aBook.chapters will return the book's chapters. But how do you get a book's pages (i.e. book.pages)? And how would you get the pages sorted by a pageNumber property? Thank you! ...

calling audio in tableview from core data

i'd like to have the user tap a cell in the tableview and hear audio. the information for the cell is loaded from core data, so i'm assuming i put the path to the audio file in core data as an attribute with type 'string'. i am completely lost as to where to go from here. how do i call the path? after a lengthy search, i haven't found ...