nsmanagedobject

[iphone] NSManagedObjectContext issues

Hi there I've set up my project with the "use coredata" option set. XCode obviously set all this up for me automatically, and now I have these lines in the app delegate header file: @interface GFree2AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; GFree2ViewController *viewController; UINavigationControll...

Why can't I get the context from the delegate with this code?

I get an annoyingly vague error from the following code: GFree2AppDelegate *delegate = [[UIApplication sharedApplication] delegate]; context = [delegate managedObjectContext]; context is defined as a NSManagedObjectContext in the .h file and is the same in the delegate. All the right files seem to be included (except for <CoreData/Cor...

NSFetchedResultsController and NSManagedObjectIDResultType crashes

I´m currently working on an ipad app in which I fetch a lot of data with core data. To keep memory profile low I´m setting the requests resultType to NSManagedObjectIDResultType and grabbing objects with the -objectWithID: Method whenever I need real data. Everything works as expected. The problem is when it comes to adding/removing Ob...

Core Data: NSManagedObject adding values "forKey" - NSNumber truncates. Alternative?

I understand that NSNumber cannot go beyond 1/10ths place. What can I use as an alternative to add a doubles (longitude/latitude) into Core Data? Using double directly does not work and NSNumber truncates the value. NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityFor...

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...

NSPredicate for an NSManagedObject's string attribute's length

Could someone please help me define a predicate that returns only NSManagedObject's who's "letters" attribute length is within a certain range? Here's the example I've been trying, I've got a feeling it's the letters.length notation, I've also tried the kvc letters.@length with no success.. What am I doing wrong? NSManagedObjectContext...

NSManagedObject and KVO vs Documentation

I have a custom NSManagedObject subclass, say, Person. I also have a UIView registered with -addObserver:forKeyPath:options:context: to observe various properties of a Person, some of which are persistent like "name" and others are just dumb KVO-compliant accessors unrelated to Core Data, like "drinking". @interface Person : NSManagedOb...

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...

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...

iPhone Core data drilldown with multiple tables

I have an app I am working on that has 2 entities linked by a relationship (many to many). I currently have the app set up so that the rootviewcontroller controls the NSManagedObject (getting, setting, deleting of the data) in the first entity. When I drill down into on of the first entities it goes to a secondview (secondviewcontroller...

problem with NSManagedObject in an if...

I'm new to objective-c, and I'm trying to make an application that categorizes objects... I want to make an "all" category but I run into a problem when creating this in my viewDidLoad. NSManagedObjectContext *context = [fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[fetchedResultsController fetchReques...

How to make Deep Copy of NSManagedObject in Core Data

I am trying to make a duplicate of an existing NSManagedObject and related sub-objects in Core Data. I can't seem to find an easy way to do this. I have an NSArrayController that is populated from a Core Data database. I want to take the object at the selectionIndex and make a deep copy, keeping it related to the same parent object an...

Is there a way to instantiate a NSManagedObject without inserting it ?

This is an iPhone dev question about CoreData. I have a user interface to insert a Transaction. once the user clicks on a plus he gets the screen and i want to instantiate my Core Data NSManagedObject entity let the user work on it. Then when the user clicks on the Save button i will call the save function. so down to code: transa...

how to tell if an NSManagedObject is new

Hi there iPhone developer. I create a new NSManagedObject and then pass it to another view controller. how can i tell in the viewController if the passed NSManagedObject is a new one or an existing one. is there a property that i can use ? Any help will be appreciated. Thanks ...

NSManagedObjectModel versionIdentifiers

The documentation for NSManagedObjectModel -versionIdentifiers says, The Core Data framework does not give models a default identifier, nor does it depend this value at runtime. For models created in Xcode, you set this value in the model inspector. I am not sure, but I think that setting version identifiers might help me as I go a...

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...

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...

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...

Core Data Saving to Database not Working

Hi, I'm a first time Core Data user/learner for iPhone, I thought that [managedObjectContext save:$error] was used to save changes to the Persistant Store. But when I reload and call NSFetch, the objects are still there. Any ideas why? for (int i ; i < [mutableFetchResults count];i++) { NSManagedObject *toDelete = [mutableFetchResu...

insertNewObjectForEntityForName returns wrong type

Hello everyone, I've been pulling my hair for the last few hours trying to figure out why insertNewObjectForEntityForName is returning NSManagedObject even though I'm trying to insert an entity of my own type. Things I have checked a thousand times: Class name is set to the correct value in the diagram designer Entity has many-to-man...