On 5 Nov 2008, at 5:28 am, Amy Gibbs wrote:

I can connect it in IB, my problem is how to reference it / use the objects in it in the code. In IB I already have the Array Controller called Purchase Order Items.


If you have an IBOutlet, let's call it 'myPurchaseOrderItems', you can see and connect it in IB, and simply refer to it in the code:

[myPurchaseOrderItems doStuff];

Note that the identifier 'Purchase Order Items' is illegal - you can't have spaces in the identifier. Thus I wonder if you've run into a common misconception which is that the name you assign an object in IB has some relevance? It doesn't - it's just a label, inaccessible to your code. Instead, you declare the IBOutlets in your code just as a normal instance variable, but prefixed by 'IBOutlet':

@interface MyClass : NSObject
{
    IBOutlet NSArrayController* myPurchaseOrderItems;

}


@end

Now if you drag a plain 'Object' into your IB window, set its class to 'MyClass', you'll see that it now has an outlet 'myPurchaseOrderItems' available for connection. You can ctrl-drag that to the object it represents. The icon label doesn't matter, it's just there to tell stuff apart (which is useful when you have a number of otherwise identical-looking icons in there) but of no use at runtime.

There's no real magic about IBOutlet, it's just a macro that stands for nothing, but in IB that is detected and made available to the UI within IB.

hth,

Graham
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to