I am new to objective C cocoa programming and I would like to know how to pass data between subviews when using a split view. The purpose is to set up a view which contains two views (top and bottom). In the topview I would like to add a combo box which holds an array of objects. When selecting an object from the list it should be displayed in the bottom view. Besides the combo box there should be a button 'Add' which allows me to set a view from a nib in the bottom view. In this view there should be a 'save' button which adds the inputed data to the array of objects and reloads the combo box of the top view including the new object. Can anybody help me out?
tnx
You should use NSNotificationCenter
for this purpose.
Here, look for this article NSNotification & NSNotificationCenter
Or it may be some independent object which conforms to some protocol. Each time user clicks the Save-button, this object will receive data from delegate method (-userDidInputTheData:(NSString*)data;
), and pass it to another subview.
You can implement all the code in your NSViewController or NSWindowViewController subclass.