core-data

ABPerson in Core Data

I'm trying to figure out to store a reference to an ABPerson in a Core Data store on an iPhone app. Ultimately, I'd like to be able to sync with a Mac version of the app (I'm assuming ABRecordIDs wouldn't be the same for the iPhone and the Mac). I was thinking of storing the record ID, name, and email and checking against those--is the...

Cocoa Core data filename?

I followed Apple's example for creating a managed object which btw was great... http://developer.apple.com/cocoa/coredatatutorial/index.html However I now want to know what "name" (filename) the user saved his data as. Does anyone know how to pull the filename from the core data object. something like this would be great... NSLog (@...

NSDecimal multiplication

Hi all, I have a core data-based app that stores several properties in the decimal and float data types. I'm writing some transient properties / virtual accessors that run calculations and return some derived numbers, but I can't seem to get NSDecimalNumber multiplication to work. Why does this not work: - (NSDecimalNumber *)discount...

Core Data NSPredicate to filter results

I have a NSManagedObject that contains a bID and a pID. Within the set of NSManagedObjects, I only want a subset returned and I'm struggling to find the correct NSPredicate or way to get what I need out of Core Data. Here's my full list: bid pid 41 0 42 41 43 0 44 0 47 41 48 0 49 0 50 43 There is a paren...

How do I set an Integer in a UITextfield using Core Data?

I can set text in my managed object like this... [editedObject setValue:textField.text forKey:editedFieldKey]; but I can't set this... [editedObject setValue:numberField.text forKey:editedFieldKey]; In the XCode Template I can set this straight into the Managed Object but like this... setValue:[NSNumber numberWithInt:200] forKey:@...

Core Data: Mass updates possible?

Is it possible to do mass updates on a given entity in Core Data? Given an Person entity for example, can I do something like this: Person.update(@"set displayOrder = displayOrder + 1 where displayOrder > 5") Or is my only option to fetch all the entities needed and then loop through and update them individually??? Thanks ...

NSPredicate problem with fetchedResultsController

Please help! I've been trying to figure this out for way too long. I can't seem to use an NSPredicate in my fetchedResultsController method: - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) return fetchedResultsController; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; ...

iPhone CoreData join

Hi guys, long time reader, first time poster. (A link to this schema is located here) http://www.weeshsoft.com/pix/DatabasePic.jpg I'm trying to get all LanguageEntries from a database for a given category.categoryName and languageset.languageSetName e.g. NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDes...

How to save objects using Multi-Threading in Core Data?

I'm getting some data from the web service and saving it in the core data. This workflow looks like this: get xml feed go over every item in that feed, create a new ManagedObject for every feed item download some big binary data for every item and save it into ManagedObject call [managedObjectContext save:] Now, the problem is of cou...

core data date format question

i have my table sorted by date - long format with time and everything. i want to format timeStamp to dd,mm,yyyy and send use it as titleforheaderinsection method...how and where do i do this? ...

EXC_BAD_ACCESS on [error localizedDescription];

This Code trows an EXC_BAD_ACCESS: NSError* error; if(![appdelegate.managedObjectContext countForFetchRequest:request error:&error]) { DLog(@"Failed to save to data store: %@", [error localizedDescription]); NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey]; if(detailedErrors != n...

iPhone core data migration date to string

I have an entity that originally started with a date attribute. I have now added a attribute that is a string that I want to hold the date, in addition to keeping the original field. I've made a mapping model, but I'm not sure what to put into "value expression" to get the new string field filled with data from the date field in the form...

Programmatically binding Core Data to dynamic NSTableColumns

I have a Core Data application with two entities: Item and Entries. Item has a dataType string variable. Item has a to-many inverse relationship to Entries. Entries has two variables: stringData and numberData. I'm programmatically creating an NSTableColumn for each Item. The cell type of the column is defined by the Item's dataType var...

iPhone CoreData: How can I track/observe all changes within a subgraph?

I have a NSManagedObjectContext in which I have a number of subclasses of NSManagedObjects such that some are containers for others. What I'd like to do is watch a top-level object to be notified of any changes to any of its properties, associations, or the properties/associations of any of the objects it contains. Using the context's ...

CoreData: Sort and Section on Relationships

I have two questions about using Core Data. Taking the typical case of Employee and Department as an example. The Employee entity has a relationship field "deparment" as to-one to Department, and the Department entity has a relationship "employee" as to-many to Employee entity. I would like to display all the employees in a TableView in...

iphone core data app crash

I'm able to complete my iphone app using core data internally. But for the first time when I'm running in simulator or on device its crashing with following error: 2010-03-18 10:55:41.785 CrData[1605:4603] Unresolved error Error Domain=NSCocoaErrorDomain Code=513 UserInfo=0x50448d0 "Operation could not be completed. (Cocoa error 513.)",...

What changes in Core Data after a save?

I have a Core Data based mac application that is working perfectly well until I save a file. When I save a file it seems like something changes in core data because my original fetch request no longer fetches anything. This is the fetch request that works before saving but returns an empty array after saving. NSEntityDescription *outp...

Core Data => Adding a related object always nil

Hello, I have two tables related: DataEntered and Model DataEntered -currentModel Model One DataEntered can have only ONE Model, but a Model can stay into many DataEntered. The relationship is from DataEntered to Model (No To Many-relathionship) and no inverse relation. XCode generates the setters for DataEnteredModel: @property (...

Why might changes be populated from one NSManagedObjectContext to another without an explicit merge?

I'm working on an object import feature that utilizes multiple threads/NSManagedObjectContexts, using http://www.mac-developer-network.com/columns/coredata/may2009/ as my guide (note that I am developing for iPhone). For some reason, when I save one of my contexts the other is immediately updated with the changes, even though I have com...

NSPredicate of special characters - iPhone

Hi everyone, I'm trying to make a predicate that includes special characters For example: [[myIngredients filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"name BEGINSWITH[c] %@", [alphabet objectAtIndex:idx]]]; Here I will get all the ingredient which starts with (let say for idx = 5) 'e'. As I have to do my app in englis...