core-data

Why I need to retain the managed object in order to process?

Here is what was going on in my code. I have a class B which contains a method retuning the fetched result R whose type is NSManagedObject to my current class A. And I assign the R to the the property pR in A. After a while another method in A tried to update the object MO and persistent it in database. However pA became nil at that time...

Cocoa touch connection and data design pattern

Hello all. My question is a design issue and it has been driving crazy over the last couple of days. I am new to cocoa touch development. I have an application that has a UINavigarion controller and a 3 views. I need to keep communicate with a WCF service and store the data on the app side. How do I create my Model (MVC) in a way tha...

Can you retrieve partial data (select specific columns instead of the entire row) from Core Data?

Does Core Data allow one to generate a statement like select FirstName, LastName from Employee instead of the entire row? In the example of Departments/Employees, let's say I want to write a navagation controller style application to display the Departments available, and when clicked, the Employees available in that Department. Lets su...

Iphone Core data - automatic saving or not ?

Hi, I started using core data and I read that I can save the data using the managedObjectContext "save" function. However, I noticed that when I fetch records from my store (sqlite db), even if I change my managed object without saving, and I reload my view , the new data is loaded. (In my viewWillAppear I fetch the data all over again...

Core Data - Setting a Relationship

Hello, I have a problem with Core Data which has left me at the end of my tether. So I was wondering if any of you wonderful people could help. Basically, I have two entities in a Core Data project. These are: Author {authorName, dateOfBirth} Book {bookName, pages} There is a one-to-many relationship from author to books called 'auth...

Many-to-many relationship constrains in Core Data

I have entities Word and Tag. Both have To-Many relationship to each other, as well as inverse. The way I need to constrain it that: if I delete a Word then only the related Tags which has no Word pointing to them will be deleted if I delete a Tag which has Words pointing to it then just nullify those set items. Is it possible to mod...

Check if attribute exists

Is there better way rather than to fetch with predicate and see the number of results in order to check that the attribute exists when adding it into managed context? I'm trying to make an attribute unique for given entity... ...

Core Data: Sort to-many relationship in NSTableView

Hello experts, I have troubles getting my NSTableView keep the contents of a to-many relationship ordered. What I have is an entity "Relationship" in a to-many relationship with an entity "Card" both managed by an NSArrayController. Card has 2 attributes, "number" (int) and "name" (String) displayed via Bindings in two columns of a NS...

Update and delete entities in two different process

Hi everybody, I'm working on an ipad application that use coredata. It download information on a database that is on the web, and record them in coredata. The application is based on a split view. My problem was to make the update of the data in background. Here is how I've done : - I've create an NSOperation, that does the download and ...

Why is Core Data so difficult to prepopulate?

This is a more a philosophical question about Apple's design decisions than a question about Core Data. Why in the world is it useful to have a model system that is so difficult to prepopulate? What are the advantages? I know you can have your program generate the sqlite file and edit it manually, but as far as I can tell, you can't do ...

How to pass NSManagedObjectContext back up to root view in UINavigationController?

I may just be passing data between views completely wrong here, so I am open to completely changing how I pass my data back and forth. My app delegate creates the NSManagedObjectContext and passes that to my main menu using a UINavigationController which makes it the root view: MainMenuViewController *mainMenuViewController = [[MainMen...

Core Data: To-Many Relationship ordered upon restart

When I restart my Core Data application with a to-many relationship my data (presented in NSTableView) is in random order. How do I keep it in that order in which the user left it before quitting the application? Of course, I can sort the data in awakeFromNib but that does not give me the precise order the user used to arrange the data ...

This SQL in Core-Data

Hi, I have two entities, A and B. A has to-Many relation with B. One B has always One A, but an A can be related to many B. The SQL would be this, without joins for a better simplification: SELECT a.id, a.name FROM a WHERE a.id IN (SELECT distinct(b.id_a) FROM b) As I import those rows from an .xml file the first time, I can easly...

Help with CoreData making a NSPredicate - Recursive Searching.

I am using CoreData for an iPhone project and I am stuck trying to build a predicate. My core data entity is Folder parent - Point to the folder class parent, can be null and is one to one. secure - An enum that holds the security type. The problem I have is that I am trying to make it so I don't show any folder that are ...

Core Data for temporary data

Is Core Data still a good option to use for the iOS even if they data will only be quite temporary. i.e – data being sent up to a server in the cloud once within range of a network, and then never needed again on the mobile device. ...

NSFetchRequest without sort descriptors

We cannot use NSFetchRequest without providing NSSortDescriptor(s). All i want to do is fetch the results and show them in the order in which they were created. Is there a built-in way to do that?, or will i have to create a new "auto-increment" field? (which goes against everything CoreData stands for, in my opinion). ...

How to verify if an SQLite file is a valid Core Data store, both generally and for specific app?

I would like to verify my Core Data store (SQLite file) before loading it so that if there is any corruption, the app won't simply crash and burn. Using the iPhone SDK, is there a way to verify an SQLite file (1) generally that it is not corrupted, and (2) more specifically, whether or not the SQLite file matches one of the possible data...

Data modeling in CoreData, (folders and documents with many children, etc)

Hi, I have used CoreData a couple of times but data modeling was very simple. This time I am supposed to implement the following: User can create documents and folders (they don't have to be real folders/directories). Folders can contain documents or other folders Documents have: 1 Title, 1 Description and 8 children Each child a...

NSFetchedResultsController refresh refetch?

I want to refetch data from my NSFetchedResultsController using a different predicate which is set using a boolean value. How do I refresh NSFetchedResultsController to fetch a new set of data? - (void)refreshFetchedResultsController { NSLog(@"refreshFetchedResultsController"); NSError *error = nil; if (![[self fetchedResul...

Delete particular row from table view

Hi Guys, In my app, I want to delete particular row from table view. Table view contents are coming from database and after getting data from database then I pushed to array. Then I reversed an array, Here after I am displaying content in table view. My problem is that when I am trying to delete the second row of table view on behalf o...