core-data

save the text on coreData

Hi I am new iphone development. In my app, i am using two textfield and i want to save the text on the dada base which is entered in textfield then i want to display it. Here i am using CoreData base. I am feeling difficult to understand all classes on the coreData base. Here i am created view based application. What are the classes req...

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

NSPredicate that is the equivalent of SQL's LIKE

I'm looking for a way to use NSPredicate to set a LIKE condition to fetch objects. In addition to that, an OR would be useful as well. I'm trying to do something where if a user searches "James" I can write an NSPredicate that will do the equivalent of: select * from users where firstname LIKE '%James%' OR lastname LIKE '%James%'; ...

Can I add a custom method to Core Data-generated classes?

I've got a couple of Core Data-generated class files that I'd like to add custom methods to. I don't need to add any instance variables. How can I do this? I tried adding a category of methods: // ContactMethods.h (my category on Core Data-generated "Contact" class) #import "Contact.h" @interface Contact (ContactMethods) -(NSString*)di...

Passing data between ViewControllers versus doing local Fetch in each VC

Hi All, I'm developing an iPhone app using Core Data and I'm looking for some general advice and recommendations on whether its acceptable to pass data between ViewControllers versus doing a local fetch in each ViewController as you navigate to it. Ordinarily I would say it all depends on various factors (e.g. performance etc) but the pa...

Core Data store corruption

A handful of customers for my iPhone app are experiencing Core Data store corruption (I assume so, since the error is "Failed to save to data store: Operation could not be completed. (Cocoa error 259.)") Has anyone else experienced this kind of store corruption? I am worried since I aim to soon push an update which performs a schema mig...

How do I access a Core Data entity's attributes in code?

I've got the following bit of code in one of my methods: ... NSNumber *selectedRecordID = [NSNumber numberWithInt:ABRecordGetRecordID(person)]; for (NSManagedObject *managedObject in fetchedResultsController.fetchedObjects) { if (selectedRecordID == managedObject.contactID) { // this line generates a compiler error // do some s...

Default Sorting with Core Data

This could well be a real stupid question, but I can't seem to sort my Core Data fetched results in the order they were saved to the persistent store. Effectively, I don't want to sort them at all, but omitting the sort descriptors from the fetch request gets me into all kinds of trouble. Is what I'm trying to achieve here possible, or...

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

iPhone SDK Core Data: Fetch all entities with a nil relationship?

I have a core data project that has Books and Authors. In the data model Authors has a to-many relationship to Books and Books has a 1-1 relationship with Authors. I'm trying to pull all Books that do not have an Author. No matter how I try it, no results are returned. In my predicate I've also tried = NIL, == nil, == NIL. Any suggestion...

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 I load PersistentDocuments into the same window

I want to open NSPersistentDocuments and load them into the same window one at a time. I'm almost there but missing some steps. Hopefully someone can help me. I have a few saved documents on the hard drive. On launch my app opens to an untitled NSPersistentDocument and creates a separate NSWindowController. When I press the button t...

Error loading my managedObjectModel

Hi guys, When I call [myAppDelegate managedObjectModel], in the retain line below, my application will crash (iPhone SDK v3.1.3): - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel != nil) { return managedObjectModel; } managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retai...

How to delete all objects for a given entity from the ManagedObjectContext

I don't want to use the reset method for my ManagedObjectContext. I only need to remove all of the objects for a specific entity, but I don't see any methods for doing this. Selecting all of the objects for a specific entity and looping over each and deleting them works, but it's very slow. ...

Array of Objects in Core Data Entity?

I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object. What is the correct logic here? Create an array of exercises in each workout? ...

Application update, insert data in coredata while preserving userdata without modelchange

Hi, I want to release an update for my app. I'm stuck on how to update the existing core data database which also stores data entered by the user. All i need to do is update a couple of records and preserve current user data. No changes are made to the model. Thanks. ...

migrate/ update core data app without erasing user data!

hello, i have a very complicated problem that i would like to share with you and maybe someone can answer it for me. before i start i have to say that i am very new in this. So, i have a coredata iphone app (much like the recipes app) that uses a pre-populated sql database. The user can add/edit his own data but the default data cannot ...

Invalid receiver type 'NSUInteger'

I have a Core Data entity whose header file looks like this: @interface MyEntity : NSManagedObject { } @property (nonatomic, retain) NSNumber * index; @end And it's implementation file looks like this: @implementation MyEntity @dynamic index; @end Now, I have a piece of code that looks like this: NSArray* selectedObects = [myE...

Accessing CoreData relationships

I have the following core data model with two entities: entity "item" which holds name, date, description and a to many relationship "image". image is optional. entity "image" holds url, name and relationship to one item. I load the executed Fetchrequest into this NSArray "entityArray" This is what I do to display my data in a UITabl...

Collection <NSCFSet: 0x1b0b30> was mutated while being enumerated. How to determine which set?

I'm doing a bunch of core data inserts and after 20k or so inserts with saves every 1-2k I get this error: Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <NSCFSet: 0x1b0b30> was mutated while being enumerated.' I'm trying to figure out which NSSet is causing this. I've done a search and the onl...