real newbie question, go easy on me, please ;-)
real newbie question, go easy on me, please ;-)
- Subject: real newbie question, go easy on me, please ;-)
- From: peter <email@hidden>
- Date: Mon, 14 Apr 2003 14:48:52 +0200
Hi
I have been tinkering around with cocoa for some time now, I don't
really know what I am doing but I hope to some day.
I want to make a simple address book search tool to include in my
application
I have adapted some of apple's address book sample code to make the
following foundation tool which actually works (a genuine achievement
for me ;-)
I want to be able to attach this code to a gui to be able to enter a
name in a text field and then see the results in a table view
Rightly or wrongly, as a first step, I have made a new cocoa
application project in PB and substituted my foundation tool main.m
file for the one in my new cocoa app - the search tool still works in
the run window - ok, so far so good.
my question is this:
how do I go about attaching my code to my nib file, so I can set the
text field ( for the search string) and the table for the output.
I know this is a really basic question, I have poured over my cocoa
books and documentation, I know the answers are there but I just need a
little nudge in the right direction
many thanks for any suggestions
Peter
here's how my code looks in the cocoa main.m file:
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
int main (int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ABAddressBook *AB = [ABAddressBook sharedAddressBook];
ABSearchElement *contactName =
[ABPerson searchElementForProperty:kABFirstNameProperty
label:nil
key:nil
value:@"mike"
comparison:kABContainsSubStringCaseInsensitive];
ABSearchElement *emailAddress =
[ABPerson searchElementForProperty:kABEmailProperty
label:nil
key:nil
value:@""
comparison:kABContainsSubStringCaseInsensitive];
ABSearchElement *contactNameAndemailAddress =
[ABSearchElement searchElementForConjunction:kABSearchAnd
children:[NSArray
arrayWithObjects:
contactName, emailAddress,
nil]];
NSArray *peopleFound =
[AB recordsMatchingSearchElement:contactNameAndemailAddress];
NSLog( [peopleFound description] );
[pool release];
return 0;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.