core-data

Add relationship between entity and property of another entity in coredata

Hi all, I have an entity with an attribute of type "string". I actually want it to be an array. So I created an another entity "array" and I want to add a many-one relationship between string and the array. So my question is: Is it possible to add a relationship between an entity and an attribute of another entity? Thanx in advance. ...

Using two different Core Data Models in the same iPhone app. How can I do it?

I am trying to use two different Core Data Models in a iPhone application, I created and correctly set up the first Core Data Model that uses SQLite as persistent object store. This one works very well and the pre-populated default store loads correctly in a Table View. Now I want to create a different Core Data Model with a different p...

How to Fetch Subquery Data from Core Data?

Using an NSPredicate, you can fetch only certain rows from Core Data using a subquery, e.g. SUBQUERY(records, $r, $r.length > 10).@count > 0. Is there a way to actually fetch the aggregated data from the subquery as a fetched property? ...

Crash invalidates url for NSPersistentStoreCoordinator

I have a Core Data app that has a bug that causes the app to crash and I have not tracked down its cause yet. One of the results of the crash is that the next time the app is started up it can not open the persistent store used by the application previously. The following error is returned from the addPersistentStoreWithType: method: ...

Core Data Utility Tutorial - Sample Code

I am following apples Core Data Utility tutorial from http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/00_introduction.html I have only just started it and have already encountered an error (more than likely my error, not anyone else's). Given the code #import <Foundation/Foundati...

One UITableViewController with many NSFetchedResultsControllers - bad idea?

My app involves a main screen with several sorting/viewing options of a set of data. Depending on what the user chooses, I may list them, e.g. alphabetically, N most recent, or grouped somehow. I started the app as a Core Data Table-based navigation app; my app delegate sets up the Core Data stack (unchanged generated code), gives the ...

Core Data - Following Keypaths

Hello, I am new to Core Data and am stumbling on the right way to set up a query. My managed object model includes the classes Apartment, Lease, and what I would otherwise call a join table called ApartmentLease. This looks like: /-----------------\ /-----------------\ /-----------------\ | Apartment | | Apartmen...

How to Store a Mixed Array in Core Data

I need to store two types of objects, Feed and Folder, in an array in Core Data. For example: Array Feed Feed Folder Feed Folder Folder …etc... I know about BWOrderedManagedObject for storing objects in order in Core Data, but I'm not sure how to store mixed objects (the array needs to be mixed, since the i...

Split nib in to several nib files with Core Data..

Currently I have one managedContext, many NSArrayControllers of entities which are all pretty interrelated, and several Windows which each make use of 1 or 2 of the NSArrayControllers. The windows use core data bindings, all set up via cocoa bindings done in IB I have 1 nib (xib) right now with everything in there. Often when using my...

iphone SDK: Arbitrary tableview row reordering with core data

What is the best way to implement arbitrary row reordering in a tableview that uses core data? The approach that seems obvious to me is to add a rowOrder attribute of type Int16 to the entity that is being reordered in the tableview and manually iterate through the entity updating the rowOrder attributes of all the rows whenever the user...

First row is not shown after insert operation, save my hair

I have a situation here and losing my hair... Very simple application driven by core data which has table view controller with add navigation button. It is very similar to Recipes sample, with couple differences There is only single Entity in model with 2 attributes The cell in main table is not customized, using default textLabel T...

Do I need more than one persistant store?

Hello everyone, Im trying to create a listing app that is core data backed.The first page lets you create as many list as you want and name them. By tapping on a name in the first view, you will be taken to that actual list where you can create the items in that list. However if I create 3 lists they each have the same data. Do I need a...

Core data predicate with group and MAX()

I have an object in core data that has 2 fields: Name and Date. Each time a person checks in it saves their name and the time they did it. Is there a way to get a list of all unique people with their last check in time using a predicate in core data? Note: i do know that 2 tables would make it easier. the sql for this would be selec...

Attribute called 'description' causes crash.

Hello, I just started playing with Core Data. I created an entity called Task with a property called Description. I opened Interface Builder and I added Core Data Entity view. Picked my entity, property and tried to build the application. After clicking on "Add" button it crashed with EXC_BAD_ACCESS. After I've renamed this attribute...

Core data prefilling sqlite db. What is Z_MAX?

Hi! I am using the SQLite Manager extension to Firefox to prefill my core data sqlite database. But when i try adding more to the prefilled database my app crashes. I suspect it has something to do with Z_MAX for my entity in the table Z_PRIMARYKEY. What should i set Z_MAX to? Is it supposed to be the number of items in my entity? So...

Determining which core Data attribute/property change triggered a NSFetchedResultsController update

I have table with a NSFetchedResultsController datasource and delegate. I have another view controller (only for displaying detail) which can be pushed from the table. However, when the vc is pushed, a call to the NSFetchedResultsController "...didChangeObject" method is received for the "update" type. However, the vc being pushed does n...

Core Data: Error, "Can't Merge Models With Two Different Entities Named 'foo' "

I'm working on an iPhone app that uses Core Data. Most times, I just test in the simulator, but occasionally pump the app down to the iPad to make sure. I've recently changed my Core Data model, and now when I send the app to the iPad, I get a SIGABRT exception telling me: Can't merge models with two different entities named 'foo' O...

Core Data, KVO, and NSInternalInconsistencyException

I'm using Core Data and KVO to look for changes in values to trigger saves to the data store. I have a table view with search hooked up to NSFetchedResultsController. When the search changes, a new results controller is made on pressing the Search button. When the user selects an item in the results table view, then the user enters a det...

Example of how to make a data factory for core data access in cocoa (iPhone)?

I have been slowly learning iPhone development and seem to keep hitting walls where I can't figure out how to do what I want to do the right way :( Basically, I want a class that handles all interactions with the data layer, for example, getting a mutable array of some list of objects from the data store. This is pretty trivial in othe...

How to determine number of objects in one-to-many relationship in CoreData

So, I've got a one-to-many relationship of Companies to Employees in CoreData (using a SQLite backend on iOS, if that's relevant). I want to create a predicate that only returns Companies that have 0 Employees associated with them. I could do it by getting all the Companies and iterating over them, but that would be (I assume) much slowe...