core-data

Core Data Ordered Join Table Efficiencies

I have a complex core data mapping in my app, simplified to the relevant pats to this question here in this image: My question is how to get sorted Foo's efficiently. Let's say that in one of my views, I have a sectioned table with every foo in it. The sections are the categories. Each section of foo (in a category) has an ordering...

Fixing predicated NSFetchedResultsController/NSFetchRequest performance with SQLite backend?

I have a series of NSFetchedResultsControllers powering some table views, and their performance on device was abysmal, on the order of seconds. Since it all runs on main thread, it's blocking my app at startup, which is not great. I investigated and turns out the predicate is the problem: NSPredicate *somePredicate = [NSPredicate predi...

NSFetchedResultController and UISearchBar implementation

Hey! I'm creating a simple Navigation-based app using core data for my iPhone and I'm trying to implement a little search. The app is baed on the "Navigation-based application"-template from Apple. The NSFetchedResultsController gets all the objects and they will be displayed in the table view. I've also have left the Plus button to add...

NSFetchedResultsController, CoreData, SectionIndex and special chars (Umlaute..)

Hi, I am having problems with NSFechtedResultsController and using the created sectionIndex(data is coming from a CoreData storage). It seems to mix up the indexTitle versus the sectionName e.g. sectionName is "Ä" and sectionIndex is "Ƒ" (0x0191) regarding the unicode char. This seems to be the case with all special chars. this can lead...

Inverse relationship warning - ask for practices on using inverse relationship

I have the Order table which contains information about a specific order, (when does it start, how many people, etc...) and that Order table has To-Many relationship to Menu Item table. I call that relationship "orderItems". The compiler gives me warning, "Order.orderedItems -- to-many relationship does not have an inverse: this is an a...

Where is the proper place to initialize data in a core data store?

For an iPhone app that has to have a bunch of data inserted before the user can do their thing on first launch, where is the correct place (in the code) to insert that data? I'm looking at between 700 - 800 records total between a few tables. I initially tried doing it in applicationDidFinishLaunching:. This worked fine for the iPhone ...

Spreadsheet-like application using Core Data?

I'm working on an application which big part will be a spreadsheet-like view (with numeric values despite of columns' and rows' names). Is there any sense in using Core Data in such a case? I'm worrying about efficiency since I know that Core Data doesn't natively support arrays and I don't feel relationships would fit very well in my ca...

How to restore the user-location in a drill down UITableViewController structure?

I have a CoreData model that contains Levels which can again contain childLevels. I represent each level with a UITableViewController listing all childLevels. When a user taps a row a new UITableViewController is pushed onto the navigationController. No problem here. How would I go about storing the user location within this table str...

Multi-property "transactions" in Core Data / NSManagedObject / NSFetchedResultsController?

Hi, Is it possible to set multiple properties of an NSManagedObject and have the NSFetchedResultsController call controllerDidChangeContent: only once? In other words, is it possible to say something like: [managedObject beginChanges]; [managedObject setPropertyA:@"Foo"]; [managedObject setPropertyB:@"Bar"]; [managedObject commitChang...

iPhone Core Data: Cascading delete across a many-to-one relationship

I have two classes A and B with a many-to-one relationship from A to B (multiple A objects may reference the same B). The question is, if the delete rule on the A side is Cascade, will B be deleted only when the last referencing A is deleted or will it be deleted the first time an associated A is deleted. The delete rule for the B side...

Cocoa Touch Updating UITableView from Core Data

Hi there, Say I have two UIViewControllers, all working under a UINavigationController: RootViewController hosts a UITableView which contains a list of domain names. CodeViewController shows a domain. A user can view any domain they like; once the domain is viewed in CodeViewController, the name is added to the store via Core Data. ...

Is there any way to automatically generate @property and @dynamic tags for Core Data primitive accessors?

Update: mogenerator works, with a template modification The Core Data documentation suggests using the -primitiveValue and -setPrimitiveValue: methods to access and change internal data of an NSManagedObject subclass rather than the slower and non-type-checked -primitiveValueForKey: and setPrimitiveValue:forKey:. I would like to adopt ...

Core Data pattern: how to efficiently update local info with changes from network?

I have some inefficiency in my app that I'd like to understand and fix. My algorithm is: fetch object collection from network for each object: if (corresponding locally stored object not found): -- A create object if (a nested related object locally not found): -- B create a related object I am doing the checking on l...

iPhone Fetch Request with localized sorting

I'm trying to get sorted localized data from a core data model. My code: NSEntityDescription *entityDescription = [NSEntityDescription entityForName: entityDescriptionValue inManagedObjectContext: context]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest s...

Iphone: How to update a table view that displays managed objects when new object is added.

I have a table view that displays managed objects (Tasks). I'd like to fetch all tasks and update the table view once a task is added or modified. Currently refresh the tasks array when NSManagedObjectContextDidSaveNotification is fired. But I'm afraid that this could be quite inefficient as the table is also updated when other objects ...

Core Data: Reset to the initial state

Hello, I have an object, I make some changes to it, but I don't want to save them, I want the 'old' values. I've tried with: [managedObjectContext rollback]; [managedObjectContext redo]; [managedObjectContext reset]; and none of them seems to work ... NSLog(@"current: %@",ingredient.name); // ===> bread [ingredient setName:@"test n...

How can a checkmark state be saved in core data?

Hello all, I have a list app where users hit the + button and enter in an item that they want to appear in the list and hit save. The table is saved with core data. The only problem is when the cell is taped I want a checkmark to be displayed. Ive enabled multiple selection with UITableViewCell *thisCell = [tableView cellForRowAtIndexP...

Should I have a NSFetchedResultsController in every view?

I'm using Core Data in my first iPhone application and trying to understand NSFetchedResultsController. It works great in my root view. Do I need to instantiate an instance in every one of my view controllers? If so, is there a template that makes this as easy as it was in my root controller (I just checked a box in the template when cre...

Core data crashes with EXC_BAD_ACCESS on one of my entities

Hopefully someone can help me debug this problem as EXC_BAD_ACCESS is the only error I receive. I've also tried turning on NSZombieEnabled, but don't get any more information as far I can tell. The problem. I have four entities: A -> B -> C -> D Where the arrow symbolizes a set: "A" contains a to-many relation to "B", "B" a to-many re...

Using filteredArrayUsingPredicate always returns an empty array for Core Data fetched objects.

I'm trying to use NSArray's filteredArrayUsingPredicate: method to filter an array of core data managed-objects. Here's an outline: NSArray *array = self.fetchedResultsController.fetchedObjects; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name contains[c] %@", searchString]; NSArray *filteredA...