Re: How to NSTableView and NSArrayConroller
Re: How to NSTableView and NSArrayConroller
- Subject: Re: How to NSTableView and NSArrayConroller
- From: "stephen joseph butler" <email@hidden>
- Date: Mon, 1 Jan 2007 08:57:14 -0600
2007/1/1, Craig Laird <email@hidden>:
#import "MyController.h"
#import "Contact.h"
@implementation MyController
- (void)awakeFromNib
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
In Cocoa, unless you're working with threads or creating your own
framework you should rarely be managing your own autorelease pool.
ABAddressBook *book = [ABAddressBook sharedAddressBook];
contact = [[NSMutableArray alloc] initWithArray:[book people]];
This isn't a very good key-value programming practice. How are
observers supposed to know that you changed the "contact" key? This
line should really be something more like:
[self setContact:[book people]]
NSEnumerator * myArrayEnumerator = [contact objectEnumerator];
NSString *thisObject;
while (thisObject = [myArrayEnumerator nextObject])
{
name = [thisObject valueForProperty:kABFirstNameProperty];
NSLog(@"First Name Is %@", name);
This isn't a good test because it's not how NSArrayController pulls
information out of the object. NSArrayController calls something like:
[thisObject valueForKey:@"name"]
Where @"name" is whatever key you've bound your table column too.
I'm not familiar with the address book framework, but I'm guessing
that it doesn't implement key-value coding for the properties you
want. You might have to wrap the information in your own NSDictionary.
_______________________________________________
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