• 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: real newbie question, go easy on me, please ;-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: real newbie question, go easy on me, please ;-)


  • Subject: Re: real newbie question, go easy on me, please ;-)
  • From: Marco Binder <email@hidden>
  • Date: Mon, 14 Apr 2003 15:17:16 +0200

Very briefly:

create a controller class, lets say, "MyController". Put your code into a method of this class (except for the autorelease pool, which you dont neccessarily need to set up manually). call the method something like "myAction". In the very same class, define two IBOutlets "nameTextField" and "resultTextField". Instead of searching for the hard coded name "mike", search for [nameTextField stringValue] and instead of NSLogging your result do [resulttextField setStringValue:<here goes your result>].

Then simply drag the header of this class into IB, make an instance of MyController there (go to Classes and then choose Instantiate from the menu). Then simply connect the outlets to the appropriate fields and for the name field, set the action to the "myAction" method in your MyController object. (All can be done by control dragging from one item to another).

Have fun!

Marco


Am Montag, 14.04.03 um 14:48 Uhr schrieb peter:

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.


--
|\ /| email@hidden http://www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
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.

References: 
 >real newbie question, go easy on me, please ;-) (From: peter <email@hidden>)

  • Prev by Date: Re: (no subject)
  • Next by Date: Custom handling for 'odoc' events
  • Previous by thread: real newbie question, go easy on me, please ;-)
  • Next by thread: Custom handling for 'odoc' events
  • Index(es):
    • Date
    • Thread