core-data

Simple Question about Core Data

Hello, I using the project named coredatabooks from apple developer examples. #import @interface Book : NSManagedObject { } @property (nonatomic, retain) NSNumber *active; @property (nonatomic, retain) NSString *title; @property (nonatomic, retain) NSString *author; @property (nonatomic, retain) NSDate *copyright; @end I need ...

Why use NSFetchedResultsController?

Hi All, Core data provides the method "executeFetchRequest" in NSManagedObjectContext class, which we can use to fetch data from tables and use it whatever the way need to. Now there is another way by using NSFetchedResultsController and providing it to UITableView to fetch and data from tables. My questions are now: Which way is fa...

Build a IS-A relationship with coredata

Hi, i need to set up a IS-A relationship with coredata. I have a Page class which has the following structure PROPERTY title PROPERTY layoutType RELATIONSHIP layout Now, i have three classes: ImageLayout, TextLayout, and SlideshowLayout. I want the Page.layout relationship to refer to one of these three classes depending on the layou...

Help with Coredata manual migration.

I'm using Core data in an iOS project. I have the data model setup for automatic data migration whenever I modify entity properties. But I recently made some changes to some entity relationships and now my app crashes with: "Can't find model for source store" I realize that resetting the app i.e deleting and re-installing will solve thi...

Import Core Data store from one app to other app

This is the best tutorial I found so far on migrating data across apps: http://www.mobileorchard.com/lite-to-paid-iphone-application-data-migrations-with-custom-url-handlers/ But it only discusses the case where you have total control over how the data is represented, such as would be the case if you were constructing your own archivab...

CoreData - Data Models

Having created an entity, and run the app successfully, I realised I had missed something out of it. I added the new attribute and now get an error regarding different data models, unable to open, SIGABRT (to paraphrase, but I think you get the picture). How do I go about resetting the data model, or will I have to create a new entity? I...

Cocoa Core Data: Using a value transformer on an array controller's arrangedObjects to provide a filtered count.

As per the title really. I have an entity which has a property "idNumber". Just as I can bind a text box to the array controller's arrangedObjects with Model Key Path "@count" to provide a count of all the objects in the array, I would like to be able to bind a text field to the array controller's arrangedObjects with a value transformer...

Core Data - Sorting results conditionally on values from a to-many-relationship

Hello I have an app with an Event entity that has a to-many-relationship to a Date entity that contains MULTIPLE startDates and endDates for each event. In my list view I need to sort the events by the next available startDate (or endDate) from the to-many-relationship. First I created a transient property in the Date entity that made a...

How do I do initial data configuration setup with CoreData?

I've got an app using CoreData as a data storage mechanism and the app needs some initial data to be configured. Are there any recommendations / what/how are you doing in order to set up the initial data? Currently I am doing it in the following way (when the app starts for the 1st time): SomeEntity *newEntity=[NSEntityDescription inse...

Weird EXC_BAD_ACCESS, what am I doing wrong?

Hi, I have a UITabBarController. One of the tab shows application "bookmarks", these bookmarks are basicly search types saved to a Core Data (SQLLite) database. When I load my application, go to the bookmark view (bookmarksViewController), it loads a function in my appDelegate (getBookmarks) and shows the result in an table. This work...

Create a Core Date Entity Instance But not want it to be stored(non-persistent)

Sometimes I need instantiate CoreDateEntity to store some infomations for temporarily using. But I needn't it be stored into DB. currently I created a similar class which have same structures as the CoreDateEntity does. It works well but I have to do many datas transfer between Two models. Is there any better way to handle this? Tha...

NSFetchedResultsController always returns NSManagedObject objects instead of custom

Hi there, I am using CoreData and have an Entity ContactList defined, which I created using the XCode xcdatamodel tool (or whatever you call that built-in thing:). I also set the Entity's Class name to "ContactList". I then used rentzsch's mogenerator (http://github.com/rentzsch/mogenerator) to generate my custom class files and added t...

Fetch Specific Number of Random Rows from CoreData

I'm using the code below to Fetch a queried set of all rows using CoreData matching the search criteria: itemType = 1. But what I need to do is to Fetch a specific number of Random rows from the data instead. For example, instead of retrieving all 100 rows of data in which the column name dataType = 1, I need to get 25 rows randomly in w...

sectionNameKeyPath through multiple relationships

Hello all, I am working on an app that uses Core Data and an NSFetchedResultsController. The model setup is like this: /-----------\ /-----------\ /-----------\ |Part | |Kit | |Source | |-----------| |-----------| |-----------| |name | |name | ...

Printing userInfo of an NSError from Core Data throws EXC_BAD_ALLOC

I'm using this code (from http://stackoverflow.com/questions/1283960/iphone-core-data-unresolved-error-while-saving/1297157#1297157) to print a more detailed description of an NSError object: - (NSString*)debugDescription { NSMutableArray* errorLines = [NSMutableArray array]; [errorLines addObject:[NSString stringWithFormat:@"Faile...

Truly bizarre data reported by Leaks using CoreData on iPad

Update 2: Apple responded to my bug report with "We believe this issue has been addressed in iOS 4.2 b1 (8C5091e). Please let us know whether or not you continue to experience this issue with the newly released software by updating this bug report." I guess this acknowledges that the issue is in their code, not mine. I'll update with res...

About getting a new NSManagedObject object.

I watch the Core Data guides, and there are two way to obtain a new NSManagedObject instances. - initWithEntity:insertIntoManagedObjectContext: of NSManagedObject class + insertnewObjectForEntityForName:inManagedObjectContext: of NSEntityDescription class Are there any difference between both methods? Or, they just mean the same thin...

Updating an Item in Core Data

Hi, I am new to Core Data. I fetch few objects into an NSMutableArray. Now I want to update an object with objectID x. My question is: How do I get the objectId for an object? and then how do I perform updates on that particular object? (eg: change 'Name' attribute and save) Thanks ...

Pre-fill SQLite database with Core Data using Django

I'm wanting to build up a pre-filled sqlite database using Django as a front-end data entry inputter; however I've read this site and on StackOverflow that isn't that easy to do; and one needs to use CSV files. That's fine if your database is pretty small - but what if you're pre-filling it with data that has relationships (ie: Customer...

What is the simplest way to know that NSManagedObject instance is new and hasn't been persisted yet?

I,ve found IsInserted property, but what if I created object without inserting it into managed context? Maybe I can use ObjectID somehow for such a purpose? ...