nsarraycontroller

NSManagedObjectContext and NSArrayController reset/refresh problem

佐手、 提交于 2019-12-04 03:44:11
问题 I'm having trouble getting my UI to reflect external changes (made by another process) to an sqlite data store. I have a fairly standard core data based NSArrayController / table view. My app gets notified that external changes have been made to the data, at which point I do a [managedObjectContext reset]; // brute force, but data set is small The problem is, doing this clears all data from the table. The array controller's arrangedObjects is also empty. I thought a subsequent

Displaying row index in an NSTableView bound to NSArrayController

醉酒当歌 提交于 2019-12-03 07:35:21
I have an NSTableView which is bound to an NSArrayController. I would like to have one of the table columns showing the index of the table row. This is easy enough to do when you implement NSTableDataSource yourself but I can't figure it out with a bound table view. I guess I'm looking here for something like the @count key path which gives me the count of arrangedObjects (that is @index) but this is obviously missing. Two clarifications: The index that is shown in each row is the index of that row and not related at all to the way the data is actually arranged in the model or array controller

NSManagedObjectContext and NSArrayController reset/refresh problem

时光毁灭记忆、已成空白 提交于 2019-12-01 19:39:12
I'm having trouble getting my UI to reflect external changes (made by another process) to an sqlite data store. I have a fairly standard core data based NSArrayController / table view. My app gets notified that external changes have been made to the data, at which point I do a [managedObjectContext reset]; // brute force, but data set is small The problem is, doing this clears all data from the table. The array controller's arrangedObjects is also empty. I thought a subsequent [arrayController fetch:nil]; might help, but it doesn't. Executing a fetch request on the managedObjectContext shows

Sort the contents of an NSScrollView, NSTableView, using Binding in ArrayController

旧时模样 提交于 2019-12-01 13:01:59
问题 I have an NSScrollView wich is bound with an ArrayController . I need to sort the content alphabetically. I've tried to do this with bindings but I can't find the right thing to bind. I used the following sortDescriptor on my ArrayController . [myArrayController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"myKey" ascending:YES selector:@selector(compare:)]]]; Do I miss a step in the process or am I not even close to sorting the content? 回答1: Did you

Correct way of updating an NSTableView in a Core Data app

邮差的信 提交于 2019-12-01 11:09:23
I have a Core Data project with an NSTableView where the columns are bound to an NSArrayController. In turn, the controller's content is bound to the main managed object context of the AppDelegate. I've sub-classed NSTextFieldCell's to provide a more customised way of displaying the data. Everything seems to work well but when I enumerate through the objects in the context and change an attribute, the NSArrayController doesn't seem to pass the new values through to the table. I know they're being changed as the sortDescriptors work and the table organises itself according to the new data but

Correct way of updating an NSTableView in a Core Data app

*爱你&永不变心* 提交于 2019-12-01 08:54:43
问题 I have a Core Data project with an NSTableView where the columns are bound to an NSArrayController. In turn, the controller's content is bound to the main managed object context of the AppDelegate. I've sub-classed NSTextFieldCell's to provide a more customised way of displaying the data. Everything seems to work well but when I enumerate through the objects in the context and change an attribute, the NSArrayController doesn't seem to pass the new values through to the table. I know they're

How to name Undo menu entries for Core Data add/remove items via bindings and NSArrayController?

别来无恙 提交于 2019-12-01 01:34:41
I have a NSTableView populated by a Core Data entity and Add Item / Remove Item buttons all wired with a NSArrayController and bindings in Interface Builder. The Undo/Redo menu items can undo or redo the add / remove item actions. But the menu entries are called only „Undo“ resp. „Redo“. How can i name them like „Undo Add Item“, „Undo Remove Item“, etc. (I am aware, something similar was asked before, but the accepted answers are either a single, now rotten link or the advice to subclass NSManagedObject and override a method that Apples documentation says about: "Important: You must not

NSPopUpButton + Bindings + Show All Option

扶醉桌前 提交于 2019-11-30 23:31:19
I'm trying to develop a NSPopUpButton that will serve as a filter to some datasource, let's say a NSArrayController that fills a table. I can bind the NSArrayController from the menu to the selection keypath so the data is properly filtered, no problem with that. Tricky part is, I want the content of this NSPopUpButton to rely on an NSArrayController using bindings, but I'd like to add a "Show All" menu item, or at least some item that doesn't come from the Core Data and performs some special action other than filtering the table using bindings and core data. I'm trying to perform something

Binding an Ordered Relationship with an NSArrayController

核能气质少年 提交于 2019-11-30 05:07:24
How does one bind an NSArrayController's content to the entities in an ordered to-many relationship? I have an unordered to-many relationship in my Core Data model, and an NSArrayController whose Content Set is bound to that relationship from the parent entity. This works fine, the data is accessible from the NSArrayController, no problem. I decided during development that it would be better to allow users to manually reorder these child objects, so I changed the relationship to an ordered one. Now, when my NSArrayController is being created from my nib, the following error is presented:

Binding a NSArrayController to a NSPopupButton & NSTextField

橙三吉。 提交于 2019-11-30 01:51:03
What I want to accomplish seems like it should be fairly straightforward. I have placed a sample project here . I have a NSArrayController filled with an array of NSDictionaries. [[self controller] addObject:@{ @"name" : @"itemA", @"part" : @"partA" }]; [[self controller] addObject:@{ @"name" : @"itemB", @"part" : @"partB" }]; [[self controller] addObject:@{ @"name" : @"itemC", @"part" : @"partC" }]; I am populating a NSPopupButton with the items in this array based on the 'name' key. This is easily accomplished with the following bindings I would then like to populate a NSTextField with the