cocoa-bindings

Binding an NSTableView to an array of strings in Swift

南笙酒味 提交于 2019-12-19 10:07:56
问题 I'm showing the contents of an array of strings with an NSTableView via binding through an Array Controller. I have "NSString" in Class Name in the attributes inspector for the Array Controller and in the Model Key Path of the Array Controller's binding inspector I have the path to my array. And I have the only column of the table bound in its Value section to the Array Controller without Model Key Path specified (it's just an array of strings). As a result, the array's strings are displayed

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

久未见 提交于 2019-12-19 03:19:05
问题 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. 回答1: 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

Binding an Ordered Relationship with an NSArrayController

浪尽此生 提交于 2019-12-18 11:57:49
问题 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

Is it necessary to override bind:toObject:withKeyPath:options: in an NSView subclass to implement binding?

与世无争的帅哥 提交于 2019-12-18 11:40:38
问题 I have an NSView subclass which has property which I want to be bindable. I've implemented the following in the subclass: myView.h: @property (readwrite, retain) NSArray *representedObjects; myView.m: @synthesize representedObjects; +(void)initialize { [self exposeBinding: @"representedObjects"]; } -(void)bind:(NSString *)binding toObject:(id)observableController withKeyPath:(NSString *)keyPath options:(NSDictionary *)options { if ([binding isEqualToString:@"representedObjects"]) {

Is it necessary to override bind:toObject:withKeyPath:options: in an NSView subclass to implement binding?

旧城冷巷雨未停 提交于 2019-12-18 11:39:04
问题 I have an NSView subclass which has property which I want to be bindable. I've implemented the following in the subclass: myView.h: @property (readwrite, retain) NSArray *representedObjects; myView.m: @synthesize representedObjects; +(void)initialize { [self exposeBinding: @"representedObjects"]; } -(void)bind:(NSString *)binding toObject:(id)observableController withKeyPath:(NSString *)keyPath options:(NSDictionary *)options { if ([binding isEqualToString:@"representedObjects"]) {

Binding a NSArrayController to a NSPopupButton & NSTextField

ぐ巨炮叔叔 提交于 2019-12-18 11:13:25
问题 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

Create view based NSTableView programmatically using Bindings in Swift

僤鯓⒐⒋嵵緔 提交于 2019-12-18 05:15:15
问题 I am working through a Cocoa in Swift book and I am stuck in a chapter on Bindings. The book uses nib files but I want to do everything programmatically (since I am joining a team that does not use nibs). The project is to create a view based table with 2 columns and the content of the table is bound to the arrangedObjects of an array controller. The array controller's content is bound to an array of Employee objects (Employee has 2 properties viz. name and salary). I was able to create the

How can I determine if Apple methods are asynchronous?

老子叫甜甜 提交于 2019-12-17 06:51:38
问题 I'm binding an NSArrayController to a managedObjectContext with mainQueueConcurrency. All that I want is to do is modify the sort properties the arrangedObjects with my own function and then call rearrangeObjects and then select some objects. But it's looking like rearrangeObjects doesn't execute synchronously. So how can I prove that, one way or the other? This works: [self.myArrayController rearrangeObjects]; // Async needed -- I believe rearrange calls a fetch, which is async dispatch

NSOutlineView and Core Data 1 → Many Relationships

 ̄綄美尐妖づ 提交于 2019-12-13 05:35:17
问题 I have a Core Data model that supports a 1 → Many relationship (1 Folder to many Phrases). At the moment I'm just displaying the Phrases on a flat NSTableView using Core Data Bindings to a NSArrayController to glue everything together - this is working happily. I'm trying to experiment with an NSOutlineView to achieve the same result but showing the folders as well. I've tried a similar binding structure that I'm already using with the NSTableView but I'm not making any headway. What steps

Is it ok to send normal messages via Interface Builder's binding’s model key path?

穿精又带淫゛_ 提交于 2019-12-13 05:16:40
问题 Is it ok to send normal messages via Interface Builder's binding’s model key path ? I want to enable some menu items only if the main window of my application is visible. I simply tried the following to see what would happen: In the bindings inspector of the menu item i bind Availability-Enabled to the AppDelegate and set the model key path to self.window.isVisible . This seems to work well, but is it meant to be used like this? Legal in the AppStore? A little exclamation mark appears next to