core-data

Need help with many-to-many relationships in core data for iPhone

Hello everyone, I have come to a roadblock in my current project. I basically have an app that is much like the Core Data Recipe app... Here is the basic structure I have in my .xcdatamodel Entity: Restaurant String: name Category: category <---- to-many relationship Entity: Category String: name Restaurant: restaurant <---- to-many re...

App crashes whenever accessing NSManagedObjects in a certain method

I have a method in a UIViewController of my iPhone application (inside a UINavigationController) that is called whenever a row is selected in the table in the ViewController's view. In this method, I access array of "Dream"'s stored in an instance field dreamsArray, which contains NSManagedObjects from my database. I can access objects f...

How does the UITableView get styled in the Core Data Recipes Sample code?

I'm trying to use Apple Core Data Sample code as a basis for my own app. I'm using this code: http://developer.apple.com/iphone/library/samplecode/iPhoneCoreDataRecipes/index.html I can't work out how that first table View is styled. I want it to be grouped (UITableViewStyleGrouped), but there seems to be no obvious place to tell it how...

Duplicate records in Core Data on fetch

Folks, I've got a bit of a puzzler involving Core Data in my iPhone project. During the viewDidLoad method in two separate view controller instances I call the following method: - (NSFetchedResultsController *)getStudentResults:(NSString *)classRoom forWeekStarting:(NSDate *)startDate andEnding:(NSDate *)endDate { AttendanceAppDel...

Multithreaded use of Core Data (NSOperationQueue and NSManagedObjectContext)

In Apple's Core Data documentation for Multi-Threading with Core Data, they list the preferred method for thread safety as using a seperate NSManagedObjectContext per thread, with a shared NSPersistentStoreCoordinator. If I have a number of NSOperations running one after the other on an NSOperationQueue, will there be a large overhead c...

Core Data/iPhone SDK question?

I've recently created a project using Core Data. I checked where xcode ask you if you want to use Core data or not and I have the core data generated code in my app delegate. I've gotten it to work after many hours of doing research. Here is what I've done to get it to work: created an instance of the managedObjectContext in the app d...

Retrieving All Of An NSTreeController's Objects.

Bit of Background info, I'm using An NSOutlineView with Core Data. This Is What I'm trying to do: Retrieve All The objects from the Outline Views Tree Controller. Retrieve the 'name' Property (Core Data) from each of these objects as a String. Finally store the Strings of the 'name' Property from all the Objects in an NSArray. For ex...

Core Data Relationships cause save error after delete

This question is probably a long shot. I can't figure out the errors I'm getting on my core data project when I save after I delete an entity. My .xcdatamodel can be seen at: http://jump.fm/BXRCG I have two main entities that I work with, an Outfit and an Article. I can create them with no problem but when I delete them I get the fo...

Core Data and xcdatamodel files vs the generated files

Is it the generated files from the data model that matters more or is the actual xcdatamodel file? And is it possible to change the ownership property from 'retain' to 'copy' for the files that are autogenerated from the xcdatamodel class? ...

CoreData add[ttt] vs set[ttt] - difference in to-many relationship?

With a one-to-many relationship: the generated classes from the xcdatamodel will have: @interface Department (CoreDataGeneratedAccessors) - (void)addEmployeeObject:(Employee *)value; - (void)removeEmployeeObject:(Employee *)value; - (void)addEmployees:(NSSet *)value; - (void)remove Employees:(NSSet *)value; @end Would 'addEmployees' r...

NSPredicate case-insensitive matching on to-many relationship

I am implementing a search field where the user can type in a string to filter the items displayed in a view. Each object being displayed has a keywords to-many relationship, and I would like to be able to filter the objects based on their keywords. Each keyword object has a name property, so I've set up an NSPredicate to do the filter...

Question for Core Data experts regarding abstract entities and inheritance relationships

My exact model is complicated to explain, so say that I'm modeling fruits and their seeds in Xcode's Core Data modeler. Here's some "psuedo-coreData-code": abstractEntity Fruit attribute sweetness relationship Seed abstractEntity Seed attribute shape concreteEntity Apple inherits Fruit concreteEntity Orange inherits Fruit concreteEn...

Adding a decorator to a class derived from NSManagedObject

I'd like to add additional behavior to a class derives from NSManagedObject and there are 4 distinct (for now) groups of behaviors. I don't need my decorator class to be persisted with CoreData -- it's purely for adding run-time behavior. However, if I try to apply the standard Decorator pattern, I can't call '[super init]', which make...

Accessing a property in NSManagedObject causes memory spike and crash

I am writing an iPhone app which uses core data for storage. All of my NSManagedObject subclasses has been automatically generated by xcode based on my data model. One of these classes looks like this: @interface Client : NSManagedObject { } @property (nonatomic, retain) NSNumber * rate; @property (nonatomic, retain) NSString * name...

Core Data: Design questions. Object wrappers or not?

I'm designing my first project using Core Data (for iPhone) and Im having some issues that might be related with my design approach. I'm doing an application that allows the user to create an Order (let's say for a restaurant). I'm using the graphic designer to model my persistence object (i.e. OrdeMO). I add MO to the ead of each name ...

Adding to a core data model from an NSArray.

I have an NSArray of strings and I want to add a certain amount of rows to the outline view depending on how many strings are in the array, each with the title of the String that was added. I think it would involve looping through the array like this. for(NSString *title in array) { JGManagedObject *theParent = [NSEntityD...

What's the quickest way to prepopulate CoreData?

My iPhone app uses CoreData and I would like to prepopulate the database. What's the best way to go about this? ...

Is Core Data more efficient than custom indexing for "as-you-type" searching ?

Hello everyone, Actually, I'm working on a Core Data based iPhone application. I have two entities which contain more than 200000 rows each and I'm experiencing some performance issues during retrieval of data. For each fetch request, I must wait between 1 and 2 seconds before getting results. I'm thinking of implementing a custom searc...

iPhone Core Data: Initializing Managed Object without a context

Hello. Is there a way to initialize a managed object outside of a context. I'm basically trying to alloc/init a Managed Object outside of a context first, then figure out if I really want to insert the object, and then inject it into the datastore using an existing managed object context. Is this possible, or does it go against the inte...

Using variable heights with NSFetchedResultsController?

What's the best way to design/use my model and NSFetchedResultsController so that I can use a table with variable height cells? Computing the height is expensive (and requires access to the model's data) so I'm caching the value in my model. However, I know that the tableview will ask for heights of all visible cells. My current thoug...