core-data

Different results from array controller and fetch request for relationship with nil value

I'm using a simple NSComparisonPredicate similar to: ("employeeDepartment != %@", department) where employeeDepartment is an optional, one-to-many relationship in Employees, and department is an NSManagedObject of Departments. When applied against the Employees entity, I'm getting different results from an NSArrayController vs an NSFetch...

How to not persist NSManagedObjects retrieved from NSManagedObjectContext

Hi I parse an xml file containing books, for each new node I go: Book *book = (Book*)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:managedObjectContext]; To obtain an NSManagedObject of my Core Data Book Entity, I then proceed to populate the managed Book object with data, add it to an array, rin...

Setting a property value on each of the results in a FetchedResults set

Hi On my Core Data Entity "Book" i have a boolean property, 'wasViewed' (NSNumber numberWithBool) that tells me if the Book was "viewed". I would like to implement a sort of "reset" this property for all my NSManagedObjects "Book". So that I can set them all to NO between sessions. I use an NSPredicate to retrieve all the Books like th...

Core Data blocking UI after asynchronous NSURLConnection didLoadResource on iPhone

Each time somebody touches a row inside a UITableView, I'm kicking off a series of asynchronous NSURLConnections, that download data and then parse and save that data into Core Data. The problem is that when I do this, the UI is responsive during the data download, but as soon as the parsing and saving begins, the UI becomes non-respons...

Good practices for multiple language data in Core Data

Hi, i need a multilingual coredata db in my iphone app. I could create different database for each language but i hope that in iphone sdk exist an automatically way to manage data in different language core data like for resources and string. Someone have some hints? ...

count number of rows in iphone coredata

I'm having trouble understanding coredata with my uitableview. I have rows being deleted and added all ok.. and the tableview displays them. However, when I then run a query on the number of elements in the database, it returns the number BEFORE I made the delete call. So an example, I have three rows. I delete two of them. I'd expect m...

iPhone - Create non-persistent entities in core data

Hi everyone, I would like to use entity objects but not store them... I read that I could create them like this: myElement = (Element *)[NSEntityDescription insertNewObjectForEntityForName:@"Element" inManagedObjectContext:managedObjectContext]; And right after that remove them: [managedObjectContext deleteObject:myElement]; then ...

Core Data and NSDate

Hi ! I read this post but I don't really understand the code... I have a core data database with an Entity and some attributes. One of them is named "myDate" and has for type NSDate. Now I want to to display each date but eliminate dates with same day-month-year and display them ascendantly . Have you got an idea? Thanks a lot ! ...

coredata using old file version on device

This is a follow on from my previous problems here. Resetting the simulator solved all my troubles before, and I've gone on to complete my App. I now have the exact same problem when installing the app onto my iPhone device. It picks up an old version of my database, which doesn't have the second entity in it, and crashes when I try to ...

iPhone: Types of persistent store

Hi, I would like to know which type of persistent store would be most appropriate in what situations, like how can I decide where to use core data, property list or archives for my iPhone application. Thanks ...

Core Data: Overkill for simple, static UITableView-based iPhone App?

Hello! I have a rather simple iPhone app consisting of numerous views containing a single, grouped table view. These views are held together in navigation controllers which are grouped in a tab bar. Simple stuff. My table views do little more than list text (like "Dog", "Cat" and "Weasel") and this data is being served from a collectio...

How decompose NSPredicate into components?

Is there any common way to decompose an expression created by [NSPredicate predicateWithFormat] to objects NSComprasionPredicate, NSExpression and other? For below example need to disassemble into components. [NSPredicate predicateWithFormat:@"(0 != SUBQUERY(collection, $x, $x.name == "Name").@Count)"]; ...

iPhone - Change entity class (NSManagedObject) to make them initializable

Hi everyone, I would like to use my custom NSManagedObject like a normal object (as well as its regular functions). Is it possible to modify the class in order to be able to initialize it like a normal object? [[myManagedObject alloc] init]; Thanks edit: to clarify the question, will it screw everything up if I change the @dynamic w...

Optimizing text searching using NSFetchedResultsController & Core Data

I have a tableview with a NSFetchedResultsController data source, displaying a list of names from the underlying Core Data SQLite store. I have implemented a search bar. When the first character is entered in the search bar, a fetch request in the following form is executed: NSPredicate *searchPredicate = [NSPredicate predicateWithForma...

Predicate for searching the first letter of each word in a string of words

I would like to create a predicate to search for a specific letter at the start of each word in a string of words e.g. all words starting with A in @"The man ate apples", would return ate and apples. Is it possible to create such a predicate? Thank you. ...

Fetching Core Data for Tableview on iPhone - Tutorial leaves me with crashes when adding items to a list

Been following the Core Data tutorial on Apple's developer site, and all is good until I have to add something to the fetched store. I am getting this error after a successful build and load when I try to add a new item to the list: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update:...

How do I Retrieve Relative Scores From a Subset of Entities in CoreData

Hi all, Sorry for the long question but I think it needs some background :S I have the following model in CoreData: A Guest can have any number of Scores in its scores relationship. A Score can have a maximum of two Guests in its guests relationship. For each pair of Guest entities I model have a Score entity with a value indicatin...

Retrieve Core Data Entities in Order of Insertion

Is there an internal ID variable or timestamp I can use in a NSSortDescriptor to retrieve Core Data entities in the order they were inserted? I would rather not have to create such properties if there is a cleaner way, though will obviously do so if there are no other alternatives. ...

Core Data - Best way to save a "number of items"

The user will have a static list of items to choose from. Using a Picker View they will choose one of the items and then select how many of them they want. Whats the best way to save this in core data? A Struct? struct order { NSInteger item; NSInteger numberOf; }; Or some sort of relationship? Many Thanks ...

NSFetchedResultsController crashing on performFetch: when using a cache

I make use of NSFetchedResultsController to display a bunch of objects, which are sectioned using dates. On a fresh install, it all works perfectly and the objects are displayed in the table view. However, it seems that when the app is relaunched I get a crash. I specify a cache when initialising the NSFetchedResultsController, and when ...