core-data

How to do this MySQL Query in Core Data?

How would I do the equivalent of this statement in Core Data? Basically I want to get a list of the 10 most occurrences of foo along w/ how many times it occurs. Basically I'm recording all of my users searches as individual entries in Core Data. I want to be able to select their 10 most searched items and display them in order starting...

Saving UIImage to core data is using up RAM. What the hey?

Here's a little background: I'm storing pretty big images (900x1200 pixels) in Core Data. These are coming from the UIImagePickerView, and I crop and resize them into this reasonable size. I'm using a pretty standard value transformer to convert between the UIImage and NSData (and back.) The program works, but it ends up getting memo...

NSTreeController fetch predicate based on transient isRoot exceptions

My document-based Cocoa application uses a NSOutlineView/NSTreeController combo, bound to the document's Core Data store. My NSTreeController has the fetch predicate isRoot == YES. isRoot is a transient boolean attribute with a default value of NO. My root model's awakeFromInsert calls: [self setIsRoot:[NSNumber numberWithBool:YES]];...

Reducing an array of objects to unique objects based on attributes

Ok. I have an array with multiple objects populated by my core data stack . Lets say each object has a name, startdate, enddate and amount attribute associated with them What I need to do is reduce this array down to only the unique objects (not just values) based on the name, which is an NSString. I've tried isEqual methods within fo...

Core Data: updating a managed object doesn't call the NSFetchedResultsControllerDelegate

I have an issue with my table view not updating when I programmatically change some existing managed object property. I would expect my NSFetchedResultsControllerDelegate to be called in such case, but it isn't. Apple doc says: An instance of NSFetchedResultsController uses methods in this protocol to notify its delegate that the co...

iPhone CoreData fetch from delegate?

Hi All, I've got a program which is working and uses Core Data for storage. However, I'm not entirely sure if I should be keeping my fetch/update methods exclusively to the app delegate? One example is for a question within the app. The question has a "left" and a "right" statement. The delegate currently creates the new QuestionVC ...

How do I use NSPredicate and a Fetch request to return an Array of entities where one Attribute contains a specific string?

I recently adapted my iPhone Application to use core data; after some research I have found that NSPredicate seems like the best way to handle my database queries. In particular, my queries will be based on 4 separate attributes. First, I need to query the database for all entities that have a specific county name. If I search for all en...

Core Data + Sync Services: How to refresh / pull the truth?

Say the user somehow managed to delete my application’s core data store. (Which has been previously synced with sync services to Mobile Me.) How do I tell core data to pull the truth (or to refresh) instead of fast sync? ...

Loading plist with array-->dictionaries-->dictionaries into core data?

HI, I have a plist that comprises an array of dictionaries that each contain multiple dictionaries of strings. That is I have a: MusicDataArray-->Mel ---->filename1 ---->filename2 ---->filename3 -->Bass ---->filename1 ---->filename2 I need to read this ...

Core Data : Post migration, additional migration code.

I wish to migrate from my version1 data model to version2, but once the migration is complete I wish to perform some custom migration code. How will I know if/when the migration occurs? Is there a migrationHasCompleed delegate method or notification? For interests sake: The custom migration code I wish to perform resizes png's in the da...

Core Data performance issues

Hi all, I have an iPhone app that has the needs to avoid inserting duplicate records, at first I thought I could just test each object in my in-memory array, create a fetch request for each object and test if it exists. But this is proving slow on the device, very slow (about 5 seconds, which is not acceptable). I have been trying to p...

iPhone: Core Data saving error

I am getting the following error when trying to save an object into my core data model: 2010-09-01 22:07:50.569 Score Card[26566:207] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UITableView.m:904 2010-09-01 22:07:50.570 Score Card[26566:207] Serious application error. E...

I try to use setReturnsDistinctResults to get distinct results with Core Data but can't make it work properly

I've an Core Data entity called "Themes" with 4 properties. One of them is called "name". This property is not unique. I would like to retrieve a list of all the names contained in the data. It seems that I need to use the setReturnesDistinctResults:YES option of the fetch request but I can't make it work. Is there anything wrong in the...

coredata sqlite malformed DB

hi, I have problems with my coredata sqlite DB, which hosts a book DB. After a crash a user experiences has the problem, that the data isn't shown properly any more in his/her tableview. This is due to the fact, that the performFetch method returns an error: [NSFetchedResultsController deleteCacheWithName:nil]; if (![[self fetchedResu...

Cannot save prepopulated sql database to core data sql database: managedObjectModel not found

my program needs to take a prepopulated sql database and then save the records to the app's database. Unfortunately for some reason the application quits in this method in the application delegate: #pragma mark - #pragma mark Core Data stack - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel_ != nil) { ret...

Should I fetch all Core Data entities upfront on iPhone?

I am building a social app that has a chatView. Message is an entity. On the usersViewController (rootViewController), I want to just display the number of unread messages from each user. But on the chatView, I want to show the messages sent between me and the selected user. How should I fetch the messages from Core Data? Is there a w...

Database changes after App is in store

Folks, I just have a quick question about updating my app after it is in the store. If I want to add an attribute to an entity in Core Data would I have to create some sort of conversion process. Regards, Stephen ...

Why do some of my core data objects have managedObjectContext set to nil?

I was having problems adding objects to one of my core data objects that has a relationship and after doing some investigating I realized it was because that objects managedObjectContext was nil (0x0). Some more investigating revealed that anytime I created an object of that type, the managedObjectContext was always nil. Every object I c...

Editing Core Data row from entity linked to managedObjectContext via relationship

Hi All I need to edit a row of data in an Entity that has a relationship with my main Entity from my fetchedResultsController, in this case "theUser" being an instance of my User entity. I basically need to edit one of the CannedMessage rows that already exist and save it. I can access the "Messages" fine as you see below, but am unsur...

Core Data or... SQLite

Hi all, I'm coming from a Ruby on Rails environment and I'm really spoiled with Active Record there. I did a small proof of concept project using sqlite on the iPhone and I realize even more how much I'm spoiled ;) For the next application I consider using Core Data (as I believe the way it works will be close to Active Record). My App...