core-data

iphone core data save not working

Im trying to save a list of Device classes (a custom class) using Core Data and retrieve it. But After I save it, my query, which is VERY simple, doesnt return any records. My call to save the records always returns YES and no errors: BOOL resultOfSave = [managedObjectContext save:&err]; My predicate for searching by the property use...

CoreData: NSManagedObject does not respond to user defined message

Using CoreData (on an iPhone app) I generated my entity classes from the model and I added some more methods to some ones. It appears that sometimes I get an exception for calling one of those methods. The exception is not random but concerns only some ManagedObject subclass (the others seem to respond correctly). Here is an example of w...

Modelling time series in Core Data

Dear all I am looking at writing an application that handles time series data and want to shove to heavy lifting data work off into Core Data. My question is this - from a speed of retrieving and ease of manipulation perspective, would it be better to model out the entities or will it likely be easier to 'store' the time series data po...

How to Deal with Temporary NSManagedObject instances?

I need to create NSManagedObject instances, do some stuff with them and then trash them or store to sqlite db. The problem is, I cannot create instances of NSManagedObject unconnected to MSManagedObjectContext and this means I have to clear up somehow after I decide that I don't need some of the objects in my db. To deal with it, I ha...

Can Core Data handle my "system vs. user data" migration needs?

My iPhone app will have read-only "system" data AND read/write "user" data (stored either using Core Data or a custom SQLite db). The user data may reference the system data. When a new version of the app is installed (e.g., via iTunes): The new system data that comes with the update should overwrite/replace the old system data The use...

DB to run on OS X server that will sync nicely with Core Data on iOS?

I am trying to plan out a few iOS/server apps for internal use. On the iOS side I'll use Core Data, but I'm not so sure what many people do on the server side. I will be running a Mac Mini with OS X Server 10.6.X. This app will need to sync when the iOS device is on the internal WiFi as well as over 3G. Some of this data will need to be ...

Core Data and UI Binding

My application builds its user interface and a core data model through code (no .xib .nib or .xcdatamodel files). I'm having trouble finding documentation on how to bind core data entity attributes (in an NSManagedObject) with the object properties of a UIView or UIViewControler such that the two are kept synchronized with each other. ...

how to remove all objects from Core Data

Hi guys, how can I remove all objects? I know I can remove one by [managedObjectContext deleteObject:objToDelete]; is it possible to delete all without iterating all array? thanks ...

Core Data - How to validate the uniqueness of an attribute within the scope of

Hi, I would like to know how to implement a validation in Core Data. What I'd like to do is ensure that an attribute is unique within the scope of a related parent object. In other words, I'm wondering how to implement the validates_uniqueness_of :field, :scope => :parent paradigm (from rails / activerecord) in Core Data. For example...

NSFetchedResultsController returning objects with null indexPaths

Details are in the comments. The following code: // Perform the fetch... NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } // Confirm that objects were fetched by counting them... NSLog(@"Number of Objects = %i", [[fe...

Objective-C NSString Transformable attribute memory leak

I have a CoreData NSManagedObject subclass, TextNarration, that has an attribute of type NSString, textURI. That class implements the NSCoding protocol methods: initWithCoder and encodeWithCoder this way: - (id) initWithCoder: (NSCoder *)coder { if (self = [super init]) { self.textURI = [coder decodeObjectForKey:@"te...

Errors when using NSFetchedResultsController with 3 related CoreData items

Hi all, I'm programming an app for an restaurant and want to show the restaurants menu in a sectioned table view. Above the table view I've got a UISegmentedControl which controls which Menu Section to display (Food or wine). The table should show the dishes separated by sections (pe. starters, meat, etc). I've got 3 related entities M...

Unit Testing for NSError's

Hallo, I am trying to set up some unit tests for code that accepts an *NSError as an argument. If there is a validation problem, then the object is not saved and the NSError condition is set. My method is: - (BOOL)validateConsistency:(NSError **)error { ... code omitted for brevity ... if (errorCondition == YES) { N...

How to add NSDate+BSJSONAdditions to the BSJSON project

Hello, I need to know how to get BSJSON to handle the NSDate that is in coredata in the json it returns null for the date, what needs to go into the category to make this work? ...

Need help performing a complex CoreData task

This would be hard with pure SQL and I'm REALLY not sure how to do it with CoreData. Is it possible to come up with a predicate or do I need to do this programmatically? Suppose (using the textbook example) I have a database of employees, some of whom are managers and some not. I want a list of managers who have an employee named "Joh...

core data for 'add to favorites' button?

i've had difficulty finding examples/tutorials/information for this. i'd like to have an 'add to favorites' button in my application. this would take a cell from one tableview and populate that cell into the 'favorites' tableview. is core data the proper direction for approaching this? i've seen some hints about using nsmutablearray and/...

Best Practice - NSError domains and codes for your own project/app

Hi all, There is a previous SO post regarding setting up error domains for your own frameworks, but what is the best practice regarding setting up error domains and custom error codes for your own project/app? For example, supposing you're working on a Core Data-intensive app with lots of validations, should you just stick with the "of...

UITableView which UITableViewCells can save and load data from core data

Hello, I'm looking for a demo project/tuturial of a table view where the cells have several textboxs so it looks like a grid. each line can be edited and save(locally but DB is better). I found this project before ... but I lost it :_( I've looked for it in the web for hours now and if you can help me I would appriciate it alot I thi...

NSFetchRequest predicate syntax

Hi, I have an entity called Task in my Core Data model. The Task entity has a transformable attribute called date. The class of the date attribute is a class called TDate (which conforms to NSCoding, therefore being a transformable attribute). TDate has a property of type NSInteger called month. In my NSFetchRequest I want to get all ...

Core Data editing attributes and getting at the unique object to edit

I'm coming from SQL and n-tiered systems and trying to work through how to use Core Data effectively for this usage: insert new managed object - I'm having no problem there delete existing managed object - I'm having no problem there editing existing managed object - problem. The problem is how do i identify that object as unique and...