Basics of Cocoa Bindings
Basics of Cocoa Bindings
- Subject: Basics of Cocoa Bindings
- From: Alex Hall <email@hidden>
- Date: Wed, 09 Sep 2015 00:04:17 -0400
I've created a new thread, because I obviously don't understand nearly as much about Cocoa Bindings as I thought I did. Adding it to my existing project is just not working out at all, and I think it's because I'm starting with too complex a model and too little comprehension of how bindings work. I've been reading the Apple documentation, as well as all the tutorials and forum posts I can find on the topic; I even sat down with a sighted person for a couple hours today and had them explain the different diagrams Apple uses to show either the flow of data in a binding or screenshots of IB while making a binding. I'd not tried having the images explained before (recall I can't see them) and I hoped that doing so would finally make everything clear. It didn't help all that much, though, as it only explained the theory, which I generally already follow. I've been fighting with this stuff for hours, and I'm beyond frustrated, so I really hope this message is going to make sense.
I think my biggest problem is what values/keys to enter where in the Bindings Inspector for my views and controller. I get that selection, selectedIndexes, objectValue, and so on are all properties of the controller, but when do you use them, and what others are commonly needed/where are they needed? When do you use a property name stored in the controller, versus one stored in your model, versus one stored in your view controller? When do you simply leave a path blank, versus needing to provide a value? Why is the "controller key" field sometimes unavailable, and sometimes not?
Speaking of keys, values, and paths, in a recent email, Ken said:
> Basically, these keyPathsForValuesAffecting<Key> methods should list the key paths of any properties used in the implementation of the computed property getter. They are the "inputs" to the computation of the computed property.
But why are they needed? Is this method taking the place of something I might do in IB, or is this something different? Why would anything other than my view controller (where this method is implemented) care about *how* a computed property is computed? If I'm standing between Alice and Bob, and I can hear both of them but they're too far apart to hear each other, I'm the controller. Bob asks me to ask Alice her hame, so I do. What this computed property situation feels like is me then asking Alice for the story behind her name, information totally unrelated to the specific detail Bob needs, and not in any way affecting my ability to get the name or to tell Bob what it is.
I'm currently binding my ArrayController to my ViewController. In the sample from Apple, though, they bound theirs to an ImageController class, if I recall the description of the figures correctly. Why did they do that instead of binding to a view controller, since they want to control a view? How did they get that controller to appear in the Bindings Inspector at all? Link:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html
My current project tries to use a model to adjust the display of a table, through an ArrayController and ViewController. Obviously, this is too complex a starting task for me. What do you recommend for a simpler app, so I can have a better chance of getting it working and seeing how it's supposed to work? I thought of something like making one edit field mimic another, so as I type into either one, the other updates. There's a whole edit protocol, though, that I'm not sure will help; I don't want it to introduce a new layer of complexity, I just want something simple to begin with.
In his most recent email, Ken said:
> So, the array controller to serve the table view will be bound to some coordinating controller (likely File's Owner in a window or view NIB, AppDelegate in the MainMenu NIB). If that's the TweetDataController, directly, then the model key path would be "currentTweetStream.tweets".
Where did Files Owner or App Delegate enter the picture? I've been using my view controller so far, and it and shared user defaults are the only two I have when I look at the bindings inspector for my ArrayController. That is, I couldn't select my app delegate or anything else even if I wanted to, and I don't see how they fit in.
I really appreciate all the time you guys are putting into trying to explain this to me. I hate to waste your time with such basic questions, but this is the best resource I can find. I've checked, and no one in any local school or college teaches Apple development; the few developers I know only do iOS; and none of my family or friends knows anything about programming at all. I've tried getting into Apple development off and on for a few years, but Xcode has finally gotten to the point where it's usable enough with VoiceOver to let me really progress. Anyway, thanks for any answers anyone is able to provide. Enjoy the Apple announcement tomorrow!
--
Have a great day,
Alex Hall
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden