cocoa-bindings

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

Table view not updating according to bindings

泪湿孤枕 提交于 2019-12-01 14:05:05
This is a very newbie question, and this is something I have done many times before, but there's something I'm missing this time. In my AppDelegate.h file I declare an NSArray and set it as a property: @interface AppDelegate : NSObject { NSArray *lines; } @property(readwrite, retain) NSArray *lines; @end And then in the AppDelegate.m file in the awakeFromNib method I alloc it: lines = [[NSArray alloc] init]; Then I have a method that sets the lines array: NSString *fileContents = [NSString stringWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop/sometextfile.txt"]

Table view not updating according to bindings

雨燕双飞 提交于 2019-12-01 12:26:40
问题 This is a very newbie question, and this is something I have done many times before, but there's something I'm missing this time. In my AppDelegate.h file I declare an NSArray and set it as a property: @interface AppDelegate : NSObject { NSArray *lines; } @property(readwrite, retain) NSArray *lines; @end And then in the AppDelegate.m file in the awakeFromNib method I alloc it: lines = [[NSArray alloc] init]; Then I have a method that sets the lines array: NSString *fileContents = [NSString

Correct way to get rearrangeObjects sent to an NSTreeController after changes to nodes in the tree?

China☆狼群 提交于 2019-12-01 09:56:20
问题 What is the appropriate way to get rearrangeObjects to be sent to an NSTreeController after changes to nodes in the tree? I have a sample application (full code below) using an NSOutlineView and NSTreeController with a simple tree of Node objects. In Version1 of the app, when you edit the name of a Node, the tree doesn't get resorted until you click the column header or use the “Rearrange” item in the menu. The latter is set up to directly send rearrangeObjects to the NSTreeController. In

Cocoa Bindings for hierarchical model

一世执手 提交于 2019-12-01 09:13:50
问题 I have a NSCollectionView based master-detail interface, where I want to display Boards in the master and Lists+Cards in the detail view. Board , holds a NSMutableArray property lists of type List List , holds a NSArray property cards of type Card Card , has a NSString property name The relationship is thus Board --> to-many List --> to-many Card The master interface is fine. The detail interface gets populated with corresponding Lists' titles for a Board. Within the detail interface I also

bind:toObject:withKeyPath:options: is one-way binding?

六月ゝ 毕业季﹏ 提交于 2019-12-01 03:48:19
I have two windows: Window A is loaded from NIB; and Window B is created programmatically. Both windows have a NStextView: the attributedString of the textview in Window A is bound to the the property text of a model using IB ; while the attributedString of the textview in Window B is bound to text property of the model using -[NSObject bind:toObject:withKeyPath:options:] method. [textview bind:@"attributedString" toObject:obj withKeyPath:@"text" options:nil]; Here is the weird thing: the textview in Window B is indeed bound to the obj.text , but the changes in the textview is never updated to

How to bind the NSMutableArray to ArrayController through xib

假如想象 提交于 2019-12-01 01:01:52
I am new to Cocoa . I am displaying a simple Tableview populated with NSMutableArray which is bound to the NSArrayController as follows [_arrController bind:@"contentArray" toObject:self withKeyPath:@"dataArray" options:nil]; Here _arrController is the IBoutlet to my NSArrayController and dataArray is my NSmutableArray with the data. I am successful in populating the Tableview when I do the binding programatically. However I am not able to achieve the same binding through the Interface Builder. I selected ArrayController in my IB , went to binding section,and tried binding under the controller

bind:toObject:withKeyPath:options: is one-way binding?

一笑奈何 提交于 2019-12-01 00:30:43
问题 I have two windows: Window A is loaded from NIB; and Window B is created programmatically. Both windows have a NStextView: the attributedString of the textview in Window A is bound to the the property text of a model using IB ; while the attributedString of the textview in Window B is bound to text property of the model using -[NSObject bind:toObject:withKeyPath:options:] method. [textview bind:@"attributedString" toObject:obj withKeyPath:@"text" options:nil]; Here is the weird thing: the

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

What does “Controller Key” mean in Interface Builder > Inspector > Bindings?

倖福魔咒の 提交于 2019-11-30 21:47:49
I can't find in the Docs where they explain all those fields and what they mean. Especially "Controller Key" is not clear to me. The Controller Key pop-up menu is a way to help you discover what keys the controller (typically a NSArrayController, NSObjectController or a NSTreeController) presents. The best example is the selection key of NSArrayControllers, which contains the set of selected objects. What is confusing is the NSObjectController presents a 'selection' key too, although the controller can control only a single object (therefore the selection = the object). I agree that it is not