cocoa-bindings

How to bind the NSMutableArray to ArrayController through xib

隐身守侯 提交于 2019-11-30 19:25:39
问题 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

Swift Bindings won't work Xcode 6 Beta 5

拥有回忆 提交于 2019-11-30 18:41:55
I'm doing a simple test program using bindings in Swift on OSX. Having an NSTableView, NSArrayController and a model class I try to hook them up together, but without success! The build compiles but gives instantly this error: Thread 1: EXC_BAD_ACCESS(code=1, address = 0x0) Code looks like this: model class: import Foundation class Name { var firstName = "Brook" var lastName = "Brooklyn" } view controller: import Cocoa class ViewController: NSViewController { dynamic var names = [Name]() // serves as the content for Array-Controller override func viewDidLoad() { super.viewDidLoad() // populate

When should I remove observers? Error about deallocating objects before removing observers

时光毁灭记忆、已成空白 提交于 2019-11-30 06:19:16
问题 I am trying to use key-value observing in one of my classes. I register the observers in the init method and remove/deregister them in the dealloc, but I get the following error which seems to occur before my dealloc method gets called, according to my debug prints. An instance 0x583870 of class TekkPoint is being deallocated while key value observers are still registered with it. Observation info is being leaked, and may even become mistakenly attached to some other object. Set a breakpoint

How to bind NSTreeController's Children to Core Data ordered to-many-relationship?

荒凉一梦 提交于 2019-11-30 05:30:14
Apple introduced ordered to-many-relationships in Core Data in Lion. I created an entity named TreeNode with an 1:1-object-relation, a 1:1-parent-relation and an ordered to-many-relationship children. Then I have an NSTreeController with the children key path set to TreeNode.children. Running the application only shows first level elements. So children is not working. Since children is an ordered to-many-relationship, the corresponding class has an NSOrderedSet children. I added a custom method - (NSArray *) childrenArray { return [children array]; } to TreeNode which works. I could not find

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:

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

佐手、 提交于 2019-11-30 04:04:07
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"]) { [observableController addObserver: self forKeyPath:@"arrangedObjects" options:NSKeyValueChangeNewKey context:nil]

Swift Bindings won't work Xcode 6 Beta 5

天大地大妈咪最大 提交于 2019-11-30 01:53:16
问题 I'm doing a simple test program using bindings in Swift on OSX. Having an NSTableView, NSArrayController and a model class I try to hook them up together, but without success! The build compiles but gives instantly this error: Thread 1: EXC_BAD_ACCESS(code=1, address = 0x0) Code looks like this: model class: import Foundation class Name { var firstName = "Brook" var lastName = "Brooklyn" } view controller: import Cocoa class ViewController: NSViewController { dynamic var names = [Name]() //

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

How to get notified of changes to models via an NSArrayController?

▼魔方 西西 提交于 2019-11-30 00:52:39
I have an NSView subclass which is bound to the arrangedObjects of an NSArrayController . When the array has an item inserted or removed the view is notified. How do I get it to be notified if a model stored in the array has an attribute changed? Do I need to add my view as an observer to every (relevant) attribute of every item added to the array? When an item is added to or removed from the array I am notified via observeValueForKeyPath:ofObject:change:context: in my NSView subclass. I am not notified of changes to the models stored in the array but I could, every time I am notified of an

Should I use Cocoa bindings for my latest project?

梦想与她 提交于 2019-11-30 00:49:12
I'm starting a project which I think would benefit from bindings (I've got a source list table, several browser views, etc), but I think it would also be quite doable, and perhaps more understandable, without them. From my limited experience I've found bindings to be difficult to troubleshoot and very "magic" (e.g. it's difficult to insert logging anywhere to figure out where stuff is breaking, everything either works or it doesn't). Is this just my inexperience talking (in which case I could sit down and spend some time just working on my understanding of bindings and expect things to start