core-data

correct use of core data for multiple access to the data - iphone/ipad

Hi everyone I got a question ;) Actually I want to use core-data in different threads. I have two UIviews that display data from the same table in the database. If a remove an entry in the first view I'm supposed save and then ask the PersistentStoreCoordinator to give me (the UIview) a brain new managed object. That what they say in ...

CoreData INSERT or REPLACE ?

Hello, I'am currently migrating an iphone application using SQLite to CoreData. I need to do an INSERT or REPLACE to add only the new content, is there a way to do this or do I have to fetch all the DB and look for existing objects and add the new ones ? Thanks. ...

Share Core Data Between Apps

Hi all, I have a Core Data-based app that keeps records of purchase receipts, and I'd like to know if I can send one specific record (i.e., one row from the SQLite table) from one phone to another via email or whatever. I'd like to have a button that says "send a copy of this receipt to so-and-so" that would email the record that could...

Creating "lookup" values in Core Data

Hi everyone, I have a Core Data entity which needs a gender property. I just need one of two, the standard male or female values. What's the best practice for this in Core Data? In the .NET world with databases I would've created a Gender table, with foreign key in the child table. I'm still getting my head around Core Data right now -...

Can a NSManagedObject own another as a property?

I've taught myself Obj-C, and have been self-teaching Cocoa, but adding Core Data to my program has given me nothing but a huge headache, thanks to me needing extensive custom logic. Here are a couple of the questions that are driving me insane. What if I want a Managed Object to own another Managed Object? It seems if I give it a to...

Core Data uniqueness

Hi everyone, Is there any way I can validate a value updated in a Core Data entity's property against values of the property in other entities in the collection? At the moment I create an entity with some default values, add it to arrangedObjects, then get the user to modify the various property values. However, I would like to check a...

NSInvalidArgumentException: Illegal attempt to establish a relationship between objects in different contexts

I have an app based on the CoreDataBooks example that uses an addingManagedObjectContext to add an Ingredient to a Cocktail in order to undo the entire add. The CocktailsDetailViewController in turn calls a BrandPickerViewController to (optionally) set a brand name for a given ingredient. Cocktail, Ingredient and Brand are all NSManagedO...

Core data query on a NSSet of NSSet

Hi everyone, I'm struggling with core data... I don't understand some things so if someone could help me, I would be very grateful! I have an entity (Recipe) with a relationship to-many with another one (Meal). I would like to select all the recipes which have no connection with a meal... so I've tried: Code: [myRecipes filteredSetUsin...

persistance in iPhone Core Data

Hi I'm trying to use core data to write a series of persistent data (NSManagedObjects) to sqlite and then read that series in to an application. I have managed to write and read a single record during a single session, but everytime I reload the app the previous data is not loaded (and sqlite manager recognizes tables but does not recog...

Core-Data: How to Delete Entities in a Relationship

Hi everyone, I have a complex Core Data graph on the iPhone. A user entity has a lot of other entities which are related one to the other with multiple relationships etc... My question is how can I delete all the related entities when I delete the user entity. Thanks in advance! ...

How to update UITableView with managed Objects?

Hey all, on viewDidLoad i init my array: NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Member" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"creationDate" ...

NSUndoManager with Core Data - Redo not working

I have a Core Data document-based app which support undo/redo via the built-in NSUndoManager associated with the NSManagedObjectContext. I have a few actions set up which perform numerous tasks within Core Data, wrap all these tasks into an undo group via beginUndoGrouping/endUndoGrouping, and are processed by the NSUndoManager. Undo wo...

How to use NSPredicate to catch child objects?

I'm new to core data and try to get all children objects of various types with one query. Say there's an "Animal" type as parent and "Cat", "Dog" and "Bird" as children. I'd like to get both cats and dogs, but not Birds in single query returned as Animal objects. Is it possible? ...

iPhone and Core Data: how to retain user-entered data between updates?

Consider an iPhone application that is a catalogue of animals. The application should allow the user to add custom information for each animal -- let's say a rating (on a scale of 1 to 5), as well as some notes they can enter in about the animal. However, the user won't be able to modify the animal data itself. Assume that when the appli...

Problems extracting information from RSS feed description field

Hi, I've built an iPhone application using the parsing code from the TopSongs sample iPhone application. I've hit a problem though - the feed I'm trying to parse data from doesn't have a separate field for every piece of information (i.e. if it was for a feed about dogs, all the information such as dog type, dog age and dog price is con...

What's an efficient way of calculating the nearest point?

I have objects with location data stored in Core Data, I would like to be able to fetch and display just the nearest point to the current location. I'm aware there are formulas which will calculate the distance from current lat/long to a stored lat/long, but I'm curious about the best way to perform this for a set of 1000+ points stored...

Core data select objects from an array - iPhone

Hi everyone, I was wondering if I could select objects based on a predicate with an array... for example Code: [NSPredicate predicateWithFormat:@"id=%@", arrayOfID]; Will it work? If no, how can I do it? Best ...

NSObjectInaccessibleException when sending NSManagedObject as object with NSNotification

I'm getting an NSObjectInaccessibleException when sending NSManagedObject as object with NSNotification. The notification is sent on the same thread as where the NSManagedObjectContext lives. It does not happen at all times and I can't track down what the exception causes. Any ideas? ...

iPhone:Updating a Core Data Model in Future Versions of an App

Hey, I am releasing a Core Data based app and wondered what I need to consider if, in an update later down the line, I need to change the model. How do I move existing user data on the device from the old data model into a new updated model? Thanks ...

Change an NSSet of NSNumber into an NSSet of int

Hi everyone, I'm using the data with core data and get an NSSet of NSNumber... my question is how can I do to change easily all the objects into int values? or can I directly get the int values from the database? Thanks ...