Re: New to Cocoa
Re: New to Cocoa
- Subject: Re: New to Cocoa
- From: Marc Weil <email@hidden>
- Date: Mon, 24 Feb 2003 06:51:59 -0500
I think it would probably be best if you went out and bought a book that
teaches you Cocoa, rather than try to learn it from the list. I tried to do
that once... It didn't work too well ;-).
The top recommended books are "Cocoa Programming for Mac OS X" by Aaron
Hillegrass, and "Cocoa Programming" by Scott Anguish, Erik Buck, and Don
Yacktman (published by Sams').
However, I can answer this question for you. Make a custom subclass of
NSObject in InterfaceBuilder (name it what you'd like, I'll call it
Controller). Then, make a single action in this class, say "buttonAction:".
Then click on the class (in the list view in IB) and, under the Classes
menu, click Create Files... (be sure that the project file for this app is
already open in Project Builder). This will automatically create the .h and
.m files for this class for you and insert it into your project. Next choose
"Instantiate" from under the Classes menu to make an instance of this new
class in your nib. Control-click and drag from the button to the new
instance of the class, and choose "buttonAction:" as the target. This is
called "wiring your interface".
Next, in Project Builder, go to the new .m file (Controller.m, in my example
here) and simply write the code inside that method, which will have a header
like this:
- (IBAction)buttonAction:(id)sender
{
}
And make it look like this (to write something to the console)
- (IBAction)buttonAction:(id)sender
{
NSLog(@"Hello World!");
}
That will print, you guessed it, "Hello World" to the console when you click
the button.
Hope this helps,
Marc Weil
P.S. If you really want to learn Cocoa, like I said, a book would be the
best way. However, feel free to contact me for specific questions. I'm not
sure what other people think of you using the list to actually *start*
learning the language, and my guess is that they aren't very fond of the
idea (since no one responded to your question ;-) ).
On 2/24/03 6:26 AM, "Vigour Vigour" <email@hidden> wrote:
>
I want to thank all users on this list for all help and suggestions but:
>
>
My questions is still not answered. I am not new to programming, only Cocoa,
>
and the best way of learning for me is to have answers on my question. I
>
know that there are targets, outlets and things like that but I don't
>
understand how to call code from a button. I will learn a lot if someone
>
will tell me how to do that.
>
>
Best regards Peter
_______________________________________________
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.