core-data

Core data migration add fields problem

I have core data model and sqlite databse with data. Entity Bla: int:f; text:baar and model class @interface Bla { } @property(retain) NSNumber *f; @property(retain) NSString *baar; @end; @implementation Bla @dynamic shared; @dynamic isEBird; @end; I add field BOOL:isGood to entity. I must do something to migrate to n...

desc limit 50 equivalent in Core Data / NSPredicate

Hi, I'm working on an iPhone and I'm using Core Data as my store. What I'd like to do is list the top 50 entities in descending order by their height. I'm struggling to find out the syntax for the predicate. ...

Why should I use Core Data for my iPhone app?

I'm working on my 2nd iPhone app and am curious about Core Data. Time on the project is limited, as is my time overall. I'm the only dev and I have a feeling that Core Data would be useful but I can't clearly explain why. Please excuse the following obfuscation .. the app needs to retrieve a list of foos from a central server. Users ...

iPhone Core Data saving multiple items at once random behavior?

Hello, I have an application that reads an rss feed, parses the xml and adds it to my database using Core Data (this is so the user can see the feed even if no internet connection is available) this all works fine. The way I am doing the parsing is: on the didStartElement i create a new Entity such as: NewsDB *newsDB = [NSEntityDescrip...

How to split an entity in Core Data migration mapping

It seems like this should be straight forward but I have not been able to find a good example of it. I have a simple Core Data entity that I want to split into two separate entities. Apple's documentation mentions it at a high level (Mapping Overview), however, it is unclear what the actual mapping model should look like to associate t...

Can you specify "select unique name from ..." with NSPredicate?

I've got some data stored in Core Data that looks something like: | name | identifier | other_stuff | I need to display the names in a UITableView, but I only want to display the names with unique name-identifier pairs. So for: John | 3 | foo Betty | 4 | foo Betty | 4 | bar I only want the query to return John, Betty. Something li...

Synchronous Distributed Objects Over NSConnection Issue

I have an application that pulls data from the web, parses them, and compiles the results in a search interface. Since the data are not co-dependant, it made sense to multi-thread the application to execute multiple fetches and parses simultaneously. I use NSInvocationOperation on a search and parse object I have written to execute thi...

Objects removed from NSArraycontroller stay in table until clicked

I have an NSArraycontroller which is bound to my application's AppDelegate's managedObjectContext. It acts as a download queue. Items are added to the NSArraycontroller programmatically I have a table which shows two of the fields in this, each a column with its value individually bound to the the said NSArraycontroller. When a new down...

Locking a single NSPersistentDocument

My application currently uses CoreData as a backend to store to a single SQL data file stored in ~/Library/Application Support/MYAPP/MyDataFile.sqlite. I know it's an unusual situation, but what is the best way to "lock" this file so that if the user decides (for whatever silly reason) to run a second copy of my app, Core Data won't frea...

Coredata: import/export objects from xml

I'm trying to write some functions that import/export only some objects of certain entity from the database of CoreData. I have googled and I found not much helpful hints so far... the only one example that helped me is this tutorial: MultiThreding code sample from this site somehow I could magage to export objects in XML, but in this e...

iPhone Core Data application will terminate save database required?

Hello, I have an application that allows you to edit some percentages, however it will only let you commit those changes if the percentages add up to 100. However because the Core Data template includes the save code in the application will terminate. If the user changed something and then exited the application, the item would be of co...

CoreData, many-to-many relationships and NSPredicate

I have a CoreData datamodel that includes a many-to-many relationship. As it turns out NSPredicate does not support many-to-many relationships. From CoreData.pdf: "You can only have one to-many element in a keypath in a predicate." As a Recipe example: Many recipes and many ingredients. Many recipes have the ingredient "salt" and "sa...

Core data and custom NSCell

I am building a toy app using core data for two entities Log (attributes text and date) and Tag with a many-to-many tags relationship from Log to Tag. I want to show logs in a table, so I: created an NSArrayController instance, LogController in IB with entity set to Log (pic) created a one-column NSTableView whose column is bound to ...

Populating a UITable with info from a website (mySQL database)

I'm looking to write an iPhone app that populates a UITable with information from a field in a database that is stored online, and when selected shows more information from the database. For example, a list of names that when tapped will show a bio for the person, some basic stats, and a picture. OR Is it possible to use CoreData, and...

iPhone Core Data: Property Persistance Durring Undo

I've got a data model built in core data for the iPhone. I also have an NSUndoManager working for that model. The problem is that I have certain properties on an entity that i don't want affected back during an undo and other properties that I do want rolled back. Is this possible without drastically changing things. If so what is the be...

Confused in getting the ManagedObjectContext from AppDelegate

I've been looking at the documentation on Core Data and trying to figure out how to arrange the Core Data Stack so it's accessible to all of my UITableViewControllers. All the examples provided by Apple show this to be implemented on the AppDelegate yet the documentation doesn't recommend this approach because it's too ridged! See link. ...

Trying to sort Core Data objects by date in table view

So I've got a Core Data setup where each object has an NSDate, and a method that returns the date as a string (ie, "12/15/2009"). The objects are displayed in a table view, and I'd like to sort them into sections based on the date string. Apple's example code in the CoreDataBooks app uses this line: NSFetchedResultsController *aFetchedR...

Cocoa error 256 core data

I have error "Cocoa error 256" when I try to save data. How to fix it? And what problem? ...

Core Data decorating with sort-compare methods

Hi I have some NSManagedObjects and I would like to write methods for sorting and comparing the properties on them. My problem is that since Core Data defines the properties as @dynamic they can not be referenced at compile time. This means that decorating an NSManagedObject with methods like this: - (NSComparisonResult) compareDateAn...

Preserving data while expanding/merging Core Data models

Two separate but related questions regarding the use of Core Data: 1) I add an entity/attribute/relationship to my Core Data model in Xcode. Is there a way to have it recognize the information in the existing storedata file and augment it, instead of simply saying that it is incompatible with the existing model? For example, if I have...