core-data

How to create a new NSFetchedResultsController using an NSManagedObject as a filter.

I am trying to figure out how to set up a new NSFetchedResultsController. Here are the steps I am taking: NSFetchedResultsController retrieves grandparent objects, which I will call "Sets" Show them up in a UITableView. Select cell. Pass selected "Set" NSManagedObject to new view controller. THIS IS WHERE I NEED HELP. I want the vie...

Core Data: sorting by count in a to-many relationship

I am currently trying to setup a NSFetchedResultsController that will order my table view based on the number of entities in a to-many relationship. I am not sure if this makes a difference when counting, but this is also an inverse relationship. I thought something like this would work just fine: NSEntityDescription *entity = [NSEntit...

Core Data set Attributes

Hi there, I'm trying to set attributes with Core Data but it won't work. Every time I call the mehtod setAveScore it throws the error [Stats setAveScore:]: unrecognized selector sent to instance 0x3364c0 Any idea what is going wrong? The call: Stats *sObj = [Stats alloc]; NSNumber *foo = [[NSNumber alloc ]initWithInt:1]; sObj.aveScor...

Core Data with json

This question is a follow up on this question. I am using the JSON Library found at http://code.google.com/p/json-framework/. My Core Data object model has a many-to-many relationship to itself and as such, has a set for its sub object. In JSON, the set is represented through an array of object ids. Nothing really exotic. When I am c...

Detecting changes to a specific attribute of NSManagedObject

How can I detect changes to a specific attribute of an NSManagedObject? In my Core Data data model, I have a Product entity that represents a product for sale. The Product entity has several attributes: price, sku, weight, numberInStock, etc. Whenever the price attribute of a Product changes, I need to perform a lengthy calculation. Cons...

Empty FetchedResultsController in Core Data

I'm using core data and I have an entity defined called LogRecord. Elsewhere this is populated with objects using: LogRecord *rec = [NSEntityDescription insertNewObjectForEntityForName:@"LogRecord" inManagedObjectContext:managedObjectContext]; [rec timestampNow]; ...

Can't write attributes int16 number in core data

I create entity Event Each entity has values1...values100 property values- indexed optional Int16 each values write 30 number Do NSString *str = [NSString stringWithFormat:@"Event", variable]; NSString *value = [NSString stringWithFormat:@"values%d", vari]; TermometrAppDelegate *app; app = (TermometrAppDelegate *)[UIApplicati...

Good Core Data tutorial?

Hey, Is anyone aware of a good detailed Core Data tutorial that focuses only on using the code (i.e. no IB involvement)? I've read the CD tutorial in the Xcode docs, and watched a few podcasts, but nothing really went from ground up. Any help is appreciated. ...

Why fetchedObject count whole entity - not attributes?

I try count number in (values8 for example) 1 of 100 attributes of Event And always got that count all number in all property of Event! NSFetchRequest *fetchRequests = [[NSFetchRequest alloc] init]; NSEntityDescription *entit = [NSEntityDescription entityForName:str inManagedObjectContext:app.managedObjectContext]; NSDictionary ...

What is the use of Core Data and why we need it in iPhone development?

Hi friends, What is meant by Core Data in iPhone? Why we need it? What is the basic methods in it? Thanks in Advance ...

Relationships in CoreData

I am quite new to core data I have read a couple of articles on Apples dev site & now am somewhat confortable with using it with one entity. Now I am working on an app that recommends recipes to users. The datadesign is somewhat like this I have these entities Item , Pantry & Recipe . Relations are as follows: ...

Core Data - submitting app store updates

Hi there Basically when I have an application in XCode and I change the sqlite/coredata database and try to run it on a device that already has the application on it then the app crashes. I have to remove the app and reinstall it. I have updated the database on an app that has already been submitted to the app store. There has been abo...

An instance of NSFetchedResultsController requires a non-nil fetchRequest and managedObjectContext

Hi, I'm trying to use core data inside an iphone application, but when I launch the application I get this error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An instance of NSFetchedResultsController requires a non-nil fetchRequest and managedObjectContext' The code is this: #import "CocktailC...

Core Data: Two Different Ways to Access Attributes, Only One Works

For the following code, of the two comment preceded lines below, only the first works. NSManagedObject * Event = [NSEntityDescription insertNewObjectForEntityForName:str inManagedObjectContext:app.managedObjectContext]; //Work but strange [Event setValue:[NSNumber numberWithInt:buf4[v+h]] forKey:value]; //Error Event.value= [NSNumbe...

Filter out Core Data entries without relationships

Hello, Assume you have an entity called Library and each Library can contain Books. It is possible for a Library to have no books at all. Is it possible to filter a fetch request so I only retrieve the Libraries that contain books? I have read that you can use the SIZE tag for NSArrays (for example, myArray[SIZE]) in an NSPredicate, bu...

How to store CGRect and other things in core data

I'm having a few teething problems with coredata, but feel it would clear things up for me greatly if someone could explain some simple cases to me. I want to put my model into coredata, and at a most simple case take advantage of undo/redo. Thing is, all the examples I see tend to store either strings or integers. What if I have a clas...

iPhone - Add Core Data To existing Project ???

I am trying to add core data functionality to an existing project. I added a data model file named "myProj.xcdatamodel" My code crashes in the following when getting the managedObjectModel What is the "momd" file? where can i get it or how can i create it? When i read the path it returns null and crashes the app. NSString *modelPath = ...

How should I store UIImages within my Core Data database?

I am developing an application which demands around 100 images or maybe more to be pre-inserted into the Core Data database along with other related information. Now I can easily add other data by just writing a few lines of code but for UIImages I am unsure how to do it without writing a lot of code. I was wondering: is there anyway t...

NSDateFormatter for NSFetchedResultsSectionInfo name

I've created a table view of "log entries" which are organized into section based on the day they were entered. I'm using Core Data so in order to do this I defined the following readonly calculated property in my NSManagedObject: - (NSString *)formattedDay { NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setTimeStyl...

exception thrown trying to insert new table row into section

I seem to be encountering a very odd problem which only occurs when trying to insert a new NSManagedObject into a new section. Basically my sections are days and individual cells are associated with times. When I MOVE an object to a day which doesn't currently have another object (table row) associated with the day, the table needs to cr...