cocoa-bindings

What is the new way of binding an NSArrayController to the managed object context of a Core Data document?

断了今生、忘了曾经 提交于 2019-11-29 23:16:42
Before Xcode went and added Storyboards for OS X apps you could connect an array controller to your document's managed object context by binding the Managed Object Context of the array controller to File's Owner with a Model Key Path of managedObjectContext . With storyboards there is no more File's Owner so where do you get the context from now? Apple's documentation is behind in this area and there aren't any obvious places to bind to in Xcode. Obviously I can just fall back to a non-storyboard route and use the old method, but there must be a new way of doing it. So I have the answer from

Cocoa Core Data newbie how-tos

坚强是说给别人听的谎言 提交于 2019-11-29 22:40:11
I am one of the great unwashed masses of .NET developers keen to try their hands at Mac OS X development. At the moment I am trying to figure out the various elements of Cocoa and getting a bit stuck on Core Data. I noticed most of the documentation and resources available on the Web involve a broad end-to-end tutorial, beginning from models, generating classes, Document-based UI, etc. Not enough seem to be focused on each bit, or at least not enough examples. Can someone please point me in the right direction, be it online material or books, that can give me detailed instruction of various

Use KVO for NSTextFields that are bound together

十年热恋 提交于 2019-11-29 14:36:58
问题 I'm having trouble getting KVO working with text fields that are bound together in a Cocoa app. I have gotten this to work when setting strings in NSTextFields with buttons but it is not working with bindings. As always, any help from Stack Overflow would be greatly appreciated. Purpose of my code is to: bind several text fields together when a number is input in one field, have the other fields automatically update observe the changes in the text fields Here's my code for MainClass which is

How do I bind my Array Controller to my core data model?

假装没事ソ 提交于 2019-11-29 12:37:57
I'm new to SWIFT programming and am trying to do a simple app to learn to use core data and bind it to display in an app. I've looked at loads of examples but all seem to be old. I am working in XCode 9. I started with a MacOS Cocoa app with Core Data. I have a simple entity called "Workout" with 4 attributes date, seconds, sport and rpe. I then added a Array Controller under the view controller scene. I added a Table view which set the Array Controller as the data source. I've added buttons to add and delete linking to array controllers add and remove methods. I think all I need to do now is

Create view based NSTableView programmatically using Bindings in Swift

馋奶兔 提交于 2019-11-29 07:52:31
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 table programmatically like below (one scroll view, one table view, 2 table columns): let tableWidth =

Cocoa Binding Mutable Dictionary with Search Field

可紊 提交于 2019-11-29 05:19:50
In my header file, I have a property declared @property (strong) NSMutableDictionary *myContents; In my implementation, I have assigned the contents of a plist (which are dictonaries) to the NSMutableDictionary. In my window, I have a NSSearchField that I would like to bind with the Dictionary and that is the problem. I have a few questions and still don't understand after reasearching. (1)Which should I use? NSObjectController, NSDictonaryController, or NSTreeController. (2)How should I bind the controller to the dictionary? Is there a "key" and a "value" that I can bind or do I have to use

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

≯℡__Kan透↙ 提交于 2019-11-29 03:22:48
问题 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

Is there a way to set up a NSCollectionView programmatically in Swift?

血红的双手。 提交于 2019-11-29 00:11:20
I'm coming from the iOS development and I am wondering if there is a way to set up a NSCollectionView programmatically like a UICollectionView in iOS? And add the NSCollectionViewItems in code. Or is the only way to set up a NSCollectionView to use bindings? Thank You! stefOCDP Thanks to @stevesliva for pointing me to this SO answer . I converted it to Swift. This is what I got. I am creating a NSCollectionView in the ViewController: import Cocoa class ViewController: NSViewController { var titles = [String]() var collectionView: NSCollectionView? override func viewDidLoad() { super

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

僤鯓⒐⒋嵵緔 提交于 2019-11-28 21:40:13
问题 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

Should I use Cocoa bindings for my latest project?

£可爱£侵袭症+ 提交于 2019-11-28 21:36:19
问题 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