Cocoa == fun
• Chris Liscio
• Chris Liscio
Neat. Dump your address book in a few simple lines:</p><p><pre>
#import
#import
</pre>
<pre>
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
</pre>
<pre>
ABAddressBook *abook = [ABAddressBook sharedAddressBook];
NSArray *people = [abook people];
int ii;
</pre>
<pre>
NSLog(@"There are %d records in the address book\n", [people count]);
</pre>
<pre>
for (ii = 0; ii NSLog(@"Person %d is %@ %@\n", ii,
[[people objectAtIndex:ii] valueForProperty:kABFirstNameProperty],
[[people objectAtIndex:ii] valueForProperty:kABLastNameProperty]);
}
</pre>
<pre>
[pool release];
}
</pre>
<p>
No wonder Apple's pushing Cocoa's ability to speed up development time. :)
</p>
<p>
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.
</p></p><p></p>