core-data

Issue with xCode generated core data stack code logic and core data sample code

In the generated code for core data stack, a save on managedObjectContext is called in applicationWillTerminate method. This is to take care of all unsaved objects in the context before exit. This has an unwanted side effect of saving any temporary objects as well. (This problem is visible in apple sample codes as well. If you click on ...

Blank String Default Value in core data designer iphone

Hi, Is there any way to set empty string as default value in core data Here the problem is, it is taking blank value in sqlite table as null and I don't want it. Thank you, Raghu, ...

core data inverse relation

Hi, Can anyone explains with an example for inverse relationship in apple core data ? Thanks In Advance, Raghu ...

core data iphone readonly relation

Hi, I have situation where I dont want to add records to the relation table. For example : I have "TRIPS" entity and it has attribute for "LOCATION_ID", I am filling it when user creates a new TRIP and select a LOCATION from the LOCATIONS entity In "LOCATIONS" entity I am allowing user to create locations and I am assigning a unique ...

Set a relationship with Core Data

I have two entities that are connected through a one-to-many relationship, let's say CategoryEntity and ItemEntity. The relationship is optional for CategoryEntity (there can be categories without items), but required for every ItemEntity. At the app's loading, the Categories already exist in the store, and I want to import ItemEntities ...

NSFetchedResultsController Crash

Following steps result in a crash in NSFetchedResultsController. I try to add the first element to a NSFetchedResultsController backed TableView. I create a temporary MO object and display a Modal View pane to add new object. On the Add Sheet (a Modal View Controller), I press Cancel Button to discard the new element. In the CancelAct...

How do I access the managedObjectContext from a controller deep in the UI?

I'm still a little fuzzy on understanding iPhone/Cocoa in general so this is probably a simple question. I have a CoreData Window-Based App for the iPhone. The rootController is a UITabBarController. The first tab view has a UINavigationController attached to it with a table in it's main view. When the App starts the objectContext is...

NSFetchedResultsController with search

What is the best practice to filter the NSFetchedResultsController data? do i need to re-initialize it every time the searchbar's text changes? I am using a UISearchDisplayControllers and i'm implementing: - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString; ...

iPhone's Core Data crashes on fetch request

I'm using the following code to grab a few objects from SQLite store (which is a prepared SQLite db file, generated with Core Data on desktop): NSFetchRequest * request = [[NSFetchRequest alloc] init]; [request setEntity: wordEntityDescription]; [request setPredicate: [NSPredicate predicateWithFormat: @"word = %@...

core data missing records iphone

Hello, I have a strange and serious problem. When I am working with core data (not saving or editing or anything) just accessing the data from entity. Sometime strangely a few records or all records are missing(deleting) from the entity when my application restarts. I checked them by opening the SQLite database. Can anyone have the ...

How do I import data from Microsoft Access / SQL Server 2005 into Core Data?

I am sitting on a ton of data in a SQL Server 2005 database, from which we dump Access databases as a cache. I want to create an iPhone app based on Core Data that can use this data from my SQL Server 2005 database, or the Access dump. Based on all of the Core Data tutorials and documentation it appears that I have to use Xcode to crea...

CoreData and mergeChangesFromContextDidSaveNotification

I'm creating a addingManagedObjectContext as a scratch pad area for new entities and then merge the new entity into my main ManagedObjectContext on 'Save', similar to how it's shown in CoreDataBooks Example. After you merge your new entity, how do you get a quick reference to it for use in displaying a detail view? Do you have to make...

How to create super/subclass programmatically in core data?

I've got a generalization in my core data model with entities named A, B, C let's say where A is a super class with subentities B and C. A is not abstract, so if I create an A NSManagedObject, I need to create and relate a single B or C subclass object. How do I make this happen? I can create the entities, but HOW do I tell the model ...

CoreData one-to-many and inverse relationship problem

I am trying to import a set of data into a CoreData persistentStore. This is read-only data that will be presented to the user at run-time. I have an entity called "Category" that has a one-to-many relationship with an entity called "Item", which in turn has an inverse relationship to a Category. As I add Items to the context, how do ...

Does CoreData on iPhone support IN predicates?

I'm trying to fetch a bunch of records of a certain type, based on a list of types defined by the user… [fetchRequest setEntity:[NSEntityDescription entityForName:@"myRecord" inManagedObjectContext:self.managedObjectContext]]; NSSet *shipTypes = [NSSet setWithObjects:[NSNumber numberWithInt:70], [NSNumber numberWithInt:71], [...

Fetch object by property in Core Data

In my iPhone project, I want to write a function that checks wether there's an object in my Core Data ManagedObjectContext with a given value for a certain property, say some_property. If there's already an object with some_property == 12, I want the function to return the object, otherwise, I want to create the object, or at least retu...

Cocoa core data self referential interface builder question

Hi there, I'm having trouble understanding how to get the following working in interface builder. I've created a Core Data model class "Person" that has a number of attributes (first name, surname, etc.) and a relationship to other persons (friends). Conceptually this is very simple. However figuring out how to get this working in IB ...

"Use Core Data for storage" checkbox

What actually happens behind the scenes when you select the "Use Core Data for storage" option when creating a new Window based project in Xcode? I'm trying to use Core Data in a project that I've already created, and I'm having a hard time figuring out how to include the framework properly in my Xcode project... Thanks! ...

Core Data to-many relationships. Are they Lazy Load?

Hi I have the typical model in Core Data (for iPhone) with Departments and Employesss (Department ->> Employee). I dont want to load all employees of a department each time I load it, so I thought I'd create the Employee as a Fetched Property. I thought I could define some Predicate like this: employee.deparmentId = department.departm...

typedef as a Core data type

I am building a Core Data model and one of my classes needs to have a variable that can best be implemented as a typedef. Right now I am implementing it as a string variable that takes three possible values, but of course this is not robust. Is there a way to implement this in the Core Data model? ...