Re: Simple Newbie Question on Calling a Method
Re: Simple Newbie Question on Calling a Method
- Subject: Re: Simple Newbie Question on Calling a Method
- From: Jerry Krinock <email@hidden>
- Date: Sat, 20 Dec 2003 21:54:25 -0800
on 03/12/20 13:02, J Nozzi at email@hidden (and others) wrote:
>
This line tells you exactly the problem. You see the
>
"+[Controller..." part? The "+" means it's a class method. A "-" would
>
mean an instance method. All the lines you've typed (-(void) myMethod;)
>
have the "-" in them because they are instance methods.
>
Yeah, I noticed that, but even reading the "Cocoa with Obj-C" for another
hour, the connection between an instance/object and its class are confusing
to me - when it's in a nib.
I can create an instance as suggested by Prachi,
Controller *myController = [[Controller alloc] init];
and it compiles, but no action occurs when I send a message to it,
obviously, because myController is not associated with anything in the nib.
If you're wondering why I find this so hard, here's where I'm coming from:
I created an *instance* of Controller (a blue cube) in Interface Builder.
Also, in IB I can create more than one instance like this, and edit the name
below each blue cube to be whatever I want, but it seems that these instance
names in IB are just decorations - they never get "compiled" anywhere.
Here's another thing that doesn't make sense to me: When I click on the
"Instances" tab, and then the "icon" view, I see the instances, but when I
click on the "list" view (or whatever they call it), I see wires terminating
at the Controller *class*. Finally, the files created by Interface Builder
produce an interface to the *class*, Controller, ignoring the instance(s).
It seems to me that these "instances" in the nib need to be related to
"instances" in the code, but how?
>
your Controller class would have to speak to a specific instance as
>
well.
Maybe if I could understand that I'd be on my way!
Thanks very much for all the help!
>
On Dec 20, 2003, at 12:17 PM, Jerry Krinock wrote:
>
> I've been trying to bring window to the front for a couple hours now,
>
> even
>
> looking in books. Probably my whole conception of the way methods are
>
> called in Objective-C is wrong.
>
>
>
> in Controller.h:
>
> @interface Controller : NSObject
>
> {
>
> IBOutlet id sorterWindow ;
>
> ... // other outlets
>
> }
>
> - (void) bringSorterWindowToFront;
>
> ... // other method declarations
>
> @end
>
>
>
> in Controller.mm:
>
> @implementation Controller
>
> - (void)bringSorterWindowToFront
>
> {
>
> [sorterWindow makeKeyAndOrderFront: self];
>
> }
>
> .. // other method definitions
>
> @end
>
>
>
> in another .mm file, I call my function with the message:
>
> [Controller bringSorterWindowToFront] ;
_______________________________________________
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.