How to NSTableView and NSArrayConroller
How to NSTableView and NSArrayConroller
- Subject: How to NSTableView and NSArrayConroller
- From: Craig Laird <email@hidden>
- Date: Thu, 28 Dec 2006 16:47:48 +1100
Hi All
I am hoping that someone can help me with this, as a newbie to Cocoa
please be nice :)
I have worked though some Tutorials on using NSArrayConroller but
they only talk and show how to add and remove
from a NSTableView.
Ok I am playing with the address-Book framework and I have created
an NSMutableArray called contact
that i want to show in a NSTableView
This is the MyController.h file
#import <Cocoa/Cocoa.h>
#import <AddressBook/AddressBook.h>
@interface MyController : NSObject
{
NSMutableArray *contact;
}
@end
This is the MyController.m file
#import "MyController.h"
@implementation MyController
- (void)awakeFromNib
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ABAddressBook *book = [ABAddressBook sharedAddressBook];
contact = [book people];
NSLog( [contact description] );
[pool release];
return 0;
}
@end
In the Interface builder I added a NSObjectController and named it
ControllerAlias and hooked it to
MyController
Then added a NSArrayConroller called Contacts, under bindings
contentArray bind to is set to ControllerAlias
Model Key Path is set to contact
Then I used the bindings to set the value of the column
bind to is set to Contacts(NSArrayController)
Controller Key is set to arrangedObjects
Model Key Path is set to name
So what else do I need to do ??
My objective is to list all the contacts in the Address Book and
then sort the alphabetically
Cheers
Craig
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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