nsmanagedobject

How to check existence of reference to an NSManagedObject?

I successfully stored and retrieved a reference to an NSManagedObject using the example found in this site http://cocoawithlove.com/2008/08/safely-fetching-nsmanagedobject-by-uri.html The problem is, the app crash whene triying to retrieve an NSManagedObject which has been deleted. I tried the method isFault on the object, but it alway...

Problem with the name of an NSEntityDescription

This problem follows on from a previous question. When I run the following line of code: NSEntityDescription *outputCellEntityDescription = [NSEntityDescription entityForName:@"OutputCell" inManagedObjectContext:[[self document] managedObjectContext]]; I get the followin...

iPhone SDK : Inserting data in tables generated by XCode

I created a data model (.xcdatamodel) in Xcode, which created .sqlite file. I can see that it has a created a few tables for metadata, alongwith a table called ZENTITY (my managed object is called entity). Can I insert data from the sqlite prompt instead of doing it programmatically? ...

Core Data - How to check if a managed object's properties have been deallocated?

I've created a program that uses core data and it works beautifully. I've since attempted to move all my core data methods calls and fetch routines into a class that is self contained. My main program then instantiates that class and makes some basic method calls into that class, and the class then does all the core data stuff behind t...

Declaring object type as NSManagedObject or class name

In Core Data, if I have a Person entity is there any difference between: NSManagedObject *aPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:[self managedObjectContext]]; or Person *aPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:[self manage...

How to not persist NSManagedObjects retrieved from NSManagedObjectContext

Hi I parse an xml file containing books, for each new node I go: Book *book = (Book*)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:managedObjectContext]; To obtain an NSManagedObject of my Core Data Book Entity, I then proceed to populate the managed Book object with data, add it to an array, rin...

iPhone - Change entity class (NSManagedObject) to make them initializable

Hi everyone, I would like to use my custom NSManagedObject like a normal object (as well as its regular functions). Is it possible to modify the class in order to be able to initialize it like a normal object? [[myManagedObject alloc] init]; Thanks edit: to clarify the question, will it screw everything up if I change the @dynamic w...

How can I duplicate, or copy a Core Data Managed Object?

I have a managed object ("A") that contains various attributes and types of relationships, and its relationships also have their own attributes & relationships. What I would like to do is to "copy" or "duplicate" the entire object graph rooted at object "A", and thus creating a new object "B" that is very similar to "A". To be more spec...

insertNewObjectForEntityForName: inManagedObjectContext: returning NSNumber bug?

I'm relatively well versed in CoreData and have been using it for several years with little or no difficulty. All of a sudden I'm now dumbfounded by an error. For the life of me, I can't figure out why insertNewObjectForEntityForName:inManagedObjectContext: is all of a sudden returning some sort of strange instance of NSNumber. GDB sa...

insertNewObjectForEntityForName:inManagedObjectContext: returning NSNumber bug?

I'm relatively well versed in CoreData and have been using it for several years with little or no difficulty. For the life of me, I can't figure out why insertNewObjectForEntityForName:inManagedObjectContext: is all of a sudden returning some sort of strange instance of NSNumber. GDB says the returned object is of the correct custom s...

How to later assign value to optional attribute of NSManagedObject in a NSManagedObjectModel having Three NSManagedObjects which is already created ?

I am using coredata framework. In my NSManagedObjectModel i am using three entities that are Class, Student and Score where class and student have one-to-many & inverse relationship and Student and Score have also inverse but one-one relationship. Score entity has all optional attributes and having default '0' decimalVaue, which is not ...

how to set Custom attribute of NSManagedObject which is calculated from other attributes ?

I am using core data framework to manage objects.i have an entity which has several attributes of decimal types. Among them is attribute which is mathematically calculated from other attributes. Ex :- @interface Marks : NSManagedObject { } @property (nonatomic, retain) NSDecimalNumber * answerGradeA; @property (nonatomic, retain) NSDe...

How do you delete a core data entry from the detail view?

I am working with an app similar to apple's core data recipes sample code. I want to be able to delete the entry from the detail view, much like apple's contacts app. The code below is deleting the 1st entry and not the selected entry. Not sure what I am doing wrong. NSIndexPath *indexPath = [myTableView indexPathForSelectedRow]; NSM...

Referencing file on disk from NSManagedObject

Hello, What would be the best way to name a file associated to a NSManagedObject. The NSManagedObject will hold the URL to this file. But I need to create a unique filename for my file. Is there some kind of autoincrement id that I could use? Should I use mktemp (but it's not a temporary file) or try to convert the NSManagedObjectId to...

Mystery Key Value Coding Key

Hello, I'm attempting to load data from an undocumented API (OsiriX). Getting the NSManagedObject like this: NSManagedObject *itemStudy = [[BrowserController databaseOutline] itemAtRow: [[BrowserController databaseOutline] selectedRow]]; works just fine. But getting the NSManagedObject like this: seriesArray = [_context executeFetchR...

Why is the class wrong for NSFetchRequest?

Hello, I am working with an undocumented API (Osirix) and I have a sister-question to the one I posted here. I am having trouble loading objects from a managed object context. With loading from API, using their instance of _context and _model 2010-05-28 14:05:13.588 OsiriX[44012:a0f] Entity: Study 2010-05-28 14:05:13.589 OsiriX[44012...

Giving another object a NSManagedObject

Alright, so I'm running into an issue with my code. What I have done is subclassed UIButton so I can give it some more infomormation that pertain to my code. I have been able to create the buttons and they work great. Capiche. However, one of the things I want my subclass to hold is a reference to a NSMangedObject. I have this code ...

How can I debug NSManagedObjects in XCode debugger?

Hi All, How do you get to the values of your Entity (sub class of NSManaged Object) when in the XCode debugger? I get lost among the NSObject and _cd_XXX structures. ...

NSPredicate syntax to exclude a given NSManagedObject

Hello all. I have a Core Data store in which many of the entities should be unique instances of their particular NSEntityDescription. I'm currently doing this by creating a new entity for a given description, then this: -(void)clearMyManagedObjectsExceptFor:(NSManagedObject*)except { NSArray *managedObjects = [ self fetchMyManagedO...

Losing NSManaged Objects in my Application

I've been doing quite a bit of work on a fun little iPhone app. At one point, I get a bunch of player objects from my Persistant store, and then display them on the screen. I also have the options of adding new player objects (their just custom UIButtons) and removing selected players. However, I believe I'm running into some memory ma...