Cocoa == fun


Neat. Dump your address book in a few simple lines:

#import #import 

int main(){    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    ABAddressBook   *abook  = [ABAddressBook sharedAddressBook];    NSArray         *people = [abook people];    int             ii;

    NSLog(@"There are %d records in the address book\n", [people count]);

    for (ii = 0; ii         NSLog(@"Person %d is %@ %@\n", ii,            [[people objectAtIndex:ii] valueForProperty:kABFirstNameProperty],            [[people objectAtIndex:ii] valueForProperty:kABLastNameProperty]);    }

    [pool release];}

No wonder Apple’s pushing Cocoa’s ability to speed up development time. :)

Don’t get me wrong, though. The equivalent in Carbon’s not much longer, but still unnecessarily so, in my opinion. I find Cocoa quite self-documenting.

Leave a Reply