core-data

How to properly use CoreData validation & error framework ?

I've created a model in Xcode, and for various attributes I have minimum & maximum values defined and that are enforced by coreData at runtime. I'm using NSManagedObject validateValue:forKey:error to check for user input values. I was a bit disappointed to see that the localized error message is not specific, and I get a "The operation...

How to programaticly access min and Max values defined in a core-data model designed with XCode ?

I was expecting to find that in the NSAttributeDescription class, but only the default value is there. Behind the scene I tought a validationPredicate was created but trying to reach it using NSDictionary* dico= [[myManagedObject entity] propertiesByName]; NSAttributeDescription* attributeDescription=[dico objectForKey:attributeKe...

iPhone: Core Data: Updating a pre-filled database in future app versions.

I am creating an app with a database of information that needs to be pre-filled. This data will change in future versions. In the same database, I also need to store user editable information since that user edited data directly relates to the pre-filled data. My question is, if I'm pre-filling the database by creating a duplicate data ...

Objective C: CoreData and aggregation

Given a CoreData-Entity with an date (days) and an ammount called Transaction. Is it with CoreData possible (and how) to aggregate/group the 'table' (with all Transactions) by Date and calculate the sum of the day in a second column/attribute? (the SQL-Solution would be SELECT date, sum(ammount) FROM transaction GROUP BY date) ...

Core Data not saving changes to Transformable property

I am saving an NSMutableArray in a Transformable property in my Core Data store. I can create the entity properly with data in the NSMutableArray and then load it out of the property, and even make changes. When I go around my app and re-access it, my changes are saved. However when I reload the app, the changes have not saved in the cor...

How to transfer Core Data store from provisioned iPhone to iPhone simulator?

I have a lot of data stored in my app on my provisioned device, and I want to do additional testing on my computer which is much faster than using the device. What is the best way to transfer the data store into the iPhone simulator so I can access it on the computer? ...

iPhoneOS Core Data migration: moving something from an entity into a file

I have a scenario where I'm moving the contents of a blob stored in a core data entity into a file. I need a way to export that data during a migration, where I know the entity that's being converted and save the blob to a file, writing the location of that file into the converted entity's appropriate attribute. I can't seem to find a w...

Using GameKit to transfer CoreData data between iPhones, via NSDictionary

I have an application where I would like to exchange information, managed via Core Data, between two iPhones. First turning the Core Data object to an NSDictionary (something very simple that gets turned into NSData to be transferred). My CoreData has 3 string attributes, 2 image attributes that are transformables. I have looked throu...

Reverting CoreData data

I have an NSTableView which is populated via a CoreData-backed NSArrayController. Users are able to edit any field they choose within the NSTableView. When they select the rows that they have modified and press a button, the data is sent to a third-party webservice. Provided the webservice accepts the updated values, I want to commit tho...

Caching results from a PHP webservice for iPhone

I'm building an app that retrieves a JSON dataset from a PHP server. The app has a view that displays a "feed" of several different newly added or updated items from the web server. The app loads 20 of the newest items to start with, and the user can subsequently load 20 more older items, and 20 more, and so on. I want this data to per...

Core Data - Entity Relationships Not Working as expected

I have set up my data model in xcode like so EntityA AttA1 AttA2 EntityB AttB1 AttB2 AttB3 I then set up the relationships EntityA Name: rlpToEntityB Destination: EntityB Inverse: rlpToEntityA To Many: Checked EntityB Name: rlpToEntityA Destination: EntityA Inverse: rlpToEntityB To Many: UnChecked i.e. relationship...

Can I use a keyPath in a predicate?

For some reason, this didn't work (although the keypath does exist): The Entity is set on the Employee. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"department.departmentName == %@", departmentName]; [fetchRequest setPredicate:predicate]; NSError *fetchError = nil; NSUInteger count = [moc countForFetchRequest:fetchReque...

NSFetchedResultsChangeInsert reported when only updates are taking place

I have a class that acts as a NSFetchedResultsControllerDelegate which is receiving messages to -(void)controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: with change type NSFetchedResultsChangeInsert, but the actual object which is the subject has with certainty not been newly inserted, only updated. So I would expect to...

Core Data and Relationships

I have two objects, a Trip and a Place. A Trip represents a journey from one Place to another Place, ie. a Trip needs a fromPlace and a toPlace. So, this is a 1-to-2 relationship, but I need to know which is the "from" and which is the "to". I am not sure how to model this in Core Data. I have created two entities (Trip, Place), and now ...

Implementation help... Subclass NSManagedObject?

I'm working on an app where I have some products that I download in a list. The downloaded products are displayed in a table and each will is showing a detail view with more information. These same products can be saved as a favorite, and for this I am using Core Data. I'd like to be able to re-use a bunch of views for displaying the p...

core data and paging

I have a database of 50,000 records. I'm using core data to fetch records from a search. A search could return 1000 records easily. What is needed to page through these records using core data and uitableview? I would like to show 100 records at a time and have 'load more' button after viewing 100 records. ...

Not saving all Core Data objects

I'm developing an iPhone app which downloads data from the internet and creates objects from that data. It is possible to create the same type of object on the device. The objects from the web should not be saved in the Core Data database, but the objects created on the device should. When I save i use this standard call: NSError ...

objectWithFieldNAme Best Practice for CoreData

Hello, I'm trying to implements some methods for my CoreData models and I'm wonndering if the way I'm doing it is a good practice. I want to implement methods of the type getObjectsWithFieldName. This methods could be used by severals views. So the way I'm doing it is implementing a Class method in the model in the following way: +(...

Accesing sub entity reletionship/property in NSFetchedResultsController

Hi! I'm trying to acces a property from a managedobject relationship in one of my entity but i keep getting a "nil" object from it. Here's a summary of the entities and there relation. Entity: House Relationships: adress (1 to 1) Entity: Adresse Properties: street (NSString) Relationships: house (1 to 1) So basically a "House" can o...

dynamically change sort descriptor for Fetched results controller

Is there a way to have the sort descriptor(s) be dynamically set for a fetched results controller on iOS? For instance, I need to have the core data results returned to me sorted based on the setting of a segmented control in the navigation title bar. The user can either click the segmented control to sort by Price or Priority. I then...