Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GregX999

macrumors newbie
Original poster
Apr 5, 2009
18
0
Hey guys,

I've been learning the whole "programming Cocoa" thing and I'm getting a bit confused about bindings. A few questions about Interface Builder:

1. What's the difference between a view and its cell? (ie: When you drag a new Text Field onto a window, you get a "Text Field", and inside that, a "Text Field Cell". Which one do you bind if you want the text field to display text based on an object?) Why are there two things instead of just one?

2. Say you have an array of objects (each object has a name and description) and an array controller bound to that array. Say you have a Table View with a list of the objects' names (bound to the array controller). Say you also have a text field. If you select an object from the table view, how do you get the text field to display the description of the selected object - and change when the selection changes?
 
1. Its all about reusability. NSCells can be plopped down in a lot of places, but NSTextField inherits a lot of abilities from NSControl and NSResponder. By having the two different classes combined together you can carry the same behavior a lot of places.

2. This is the perfect place to use NSArray controllers and Cocoa bindings.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.