core-data

Group by weekdays with Core Data

In my Core Data Model i've got an entity that has a date attribute and as the title suggests, i'd like to group this entity by (week)days. The problem is, the dates are stored more or less as timestamps and i don't know how to create a predicate that is capable of grouping/filtering my entities approprioately. I've figured out that i w...

Tableview with sections managed by fetched results controller

Hi, I'm quite new to CoreData and need help with one issue. I have tableview which simply lists cities stored in SQLite db. City is defined by "cityId" and "name" attributes. Data are fetched using NSFetchedResultsController and everything works fine except that I can't figure out how to make FetchedResultsController to group cities by...

Steps to migrate Core Data databases for shipped iPhone apps

What are the recommended steps to be done for migrating Core Data DB changes for updated iPhone apps already shipped? Is there any prior step one need (should) have done before shipping a Core Data app? ...

Is there a way to use NSPredicate to issue an NSDeleteRequest vs. an NSFetchRequest in Core Data?

I don't think the class NSDeleteRequest exists, but I want it to. I can make an NSPredicate and use NSFetchRequest to issue: select * from foo where x=y How can I issue: delete from foo where x=y ? The only way to delete 1000's of rows seems to be to fetch them, loop thru them, and call delete on each NSManagedObject. Is that righ...

Cocoa Touch: When does an NSFetchedResultsController become necessary to manage a Core Data fetch?

I'm developing an iPhone application that makes heavy use of Core Data, primarily for its database-like features (such as the ability to set a sort order or predicate on fetch requests). I'm presenting all the data I fetch in various UITableViewControllers. What I'd like to know is a rough idea of how many objects I can fetch before it ...

How do I initialize a store with default data in a CoreData application?

Hi! I'm doing an iPhone application. In this app, I just want to have a database to be used as a looked up table for values in my app. The only thing the database will do was to supply me the values I needed depending on the query of the program. It won't do any addition or deletion in the database. My question was how do I initialize a ...

CoreData Error

Hi, I am developing an application in cocoa .I am facing a critical problem now.I am deleting an entries of an object named "Directory" in coredata using the following code NSEnumerator *tempDirectories = [[folderArrayController arrangedObjects] objectEnumerator]; id tempDirectory; while (tempDirectory = [tempDirectories n...

Establishing one to many relationship between 2 entities

I have an entity group and another entity as members.One particular group may have a number of members but a particular member belongs to one particular group only.In short i have a one to many relationship between group and member.How should i go about adding the relationship in my data model class. Thanks in advance ...

Where to place the "Core Data Stack" in a Cocoa/Cocoa Touch application

In the iPhone Core Data Template, Apple places the Core Data Stack in the App Delegate. My initial inclination however is to move this code into it's own class whose responsibility is to handle the management of the Core Data Stack. Do you typically encapsulate this functionality within its own class or do you leave it in the App Deleg...

When does application state belong in Core Data instead of NSUserDefaults?

I'm trying to decide whether some application state, specifically the selected item in a list, should be stored in Core Data or NSUserDefaults. Generally I believe that application preferences and state should persist in NSUserDefaults, and model-level data should persist elsewhere, say in Core Data. My model so far is: Should the dat...

How to manually manage Core Data relationships when deleting

I have a Core Data entity, which contains a relationship to another entity. Under certain circumstances, I need to delete the managed objects in the relationship, and at other times no action needs to be taken. I have the Delete Rule on the entity is No Action because of this manual management. The problem I have is, where is the best...

Needs solution to store XML as object or as such in iPhone Apps

Hi, I am a beginner to iPhone App development. Please help me out. In my iPhone application, I am making an API request and getting an XML. I have to parse it, store it in a object(or xml as such) and also display it in my application at a later point of time (Its more like storing the current state). I figured out how to request A...

NSPredicates and double to-n relationships

Hi! I have an Core Data entity called Album; an album has a relationship to Song entities (called songs), and each Song has an arbitrary count of Tag entities (in a tags property), tags have a name. Now I want to check whether any of the songs in an Album contain a Tag; using a single NSPredicate. An ideas that came to mind was: [NSP...

Iphone Core Data Internal Inconsistency

This question has something to do with the question I posted here: http://stackoverflow.com/questions/1230858/iphone-core-data-crashing-on-save however the error is different so I am making a new question. Now I get this error when trying to insert new objects into my managedObjectContext: *** Terminating app due to uncaught exception ...

how to create custom sections in a tableview based on coredata entities

I'm just starting to learn coredata. In my core data model I have a date stamp (of type NSDate) which includes the date and time (I need this information). Now I would like to organize the Core Data table into sections by days. How can I do this. The only samples I found directly use a core data entity to create the sections, in this ca...

How Do I Comment A Core Data Schema?

I am new to Core Data, and am designing a schema. I would like to to comment things like: This what the field name means, and this is what it should contain Here is why we have this relationship This integer corresponds to this enum this field is in this encoding, or can only contain [a-zA-Z0-9-] I've read over the Xcode Entity Mode...

Model for localizable attribute values in Core Data Entity?

If I want to create a entity in Core Data that has attributes with values that should be localizable I'm wondering how the most efficient way would look like? As a example let's assume the following structure: Book name (localizable) description (localizable) author An localized book entry would look like this: name: ...

iphone Core Data Unresolved error while saving

I am getting a strange error message from the core data when trying to save but the problem that the error is not reproducible ( it appears at different times when doing different tasks) the error message: Unresolved error Domain=NSCocoaErrorDomain Code=1560 UserInfo=0x14f5480 "Operation could not be completed. (Cocoa error 1560.)", { ...

Syncing Core Data model between Mac and iPhone

I am currently building my Core Data model, which I would like to sync between the Mac and iPhone versions of my application. I will be using Bonjour for device discovery, etc but I have a question regarding the data sync part of the problem. So far I have added a UID and modification timestamp to each object that will be involved in s...

NSInternalInconsistencyException when last row is removed from the section

I have an iPhone 3.0 application that work with requests using Core Data. It has a view with all requests grouped by request status (sectionNameKeyPath:@"status" ). Also it has another view where the user can change the request status. I have a problem when there is one row/request with in specific group and the user edits the status of...