• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to NSTableView and NSArrayConroller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: How to NSTableView and NSArrayConroller (From: Craig Laird <email@hidden>)

  • Prev by Date: Re: selection stays in NSTextView
  • Next by Date: Re: Completely remove a window (from NSApp)?
  • Previous by thread: Re: How to NSTableView and NSArrayConroller
  • Next by thread: Way to determine size of a menu?
  • Index(es):
    • Date
    • Thread