Sending messages to objects created in Interface Builder
I'm quite new to Cocoa, Objective-C and OOP in general. I'm learning every day. According to 'Cocoa Programming for Mac OS X for DUMmIES' you can create an object in Xcode like this:
myObject = [[Class_name alloc] init];
Afterwards you'll be able to send it messages according to the methods decladed in Class_name
. So far so good. But yesterda开发者_Go百科y I followed this tutorial: Intro to Bindings and noticed something weird. According to the tutorial, you mustcreate an NSArrayController object within Interface Builder. But if you want to add a row to the array, managed by the controller, with values from let's say a couple of NSTextFields, you need to call it's AddObject method, but how? I don't know the objects name or identifier, right?
Simply create an outlet
IBOutlet NSArrayController *arrayController;
and connect your arrayController
to it in IB;
To call its method use [arrayController methodName];
精彩评论