discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One Question


From: Pascal Bourguignon
Subject: Re: One Question
Date: Thu, 26 Apr 2001 05:31:52 +0200 (CEST)

"Yen-Ju Chen" <address@hidden> wrote:
 
>   I met a strange question.
>   I design a Delegate class as the delegate of NSApplication,
>   and this Delegate will create one or more Window class to show up the
> window.
>   Then if Window class has a method, Black,
            ^^^^^^^^^^^^
>   and the Delegate want to use this Black method,
>   I write this code in Delegate class:
> 
>  - (void) Red {
> 
>   Window *myWin = [NSApp keyWindow];
>   [myWin Black];
     ^^^^^ is a Window instance!
> 
>   NSLog (@"Red");
> 
> }
> 
>   When no Window created, the program just shows "Red", which is expected.
>   When I create the Window, the program has a error:
>   NSWindow can't recognize Black.
>   Is it right ?
> 
>   I set one menu to use the Red method, action: @selector(Red);
>   but I don't think it matters.
> 
>   So how could I call Black in Window from Delegate ?
> 
>   PS. Delegate is inherited from NSObject,
>   and Window from NSWindow.
> 
>   Thanx a lot!!

Class methods  are used  by the classes  to answer to  class messages,
ie. messages sent to the class.


Instance methods  are used by  the instances of  a class to  answer to
instance messages.


     @interface AClass
     {
     }

        +(id)alloc;
        -(id)init;

        +(void)aClassMethod;

        -(void)anInstanceMethod;

     @end


     {
        AClass* anInstance=[[AClass alloc] init];
        //                          ^^^^^  ^^^^
        //                            |      |___ an instance method 
        //                            |___________a class method 

        [anInstance anInstanceMethod];

        [AClass     aClassMethod];

        [[anInstance class] aClassMethod];
     }



-- 
__Pascal_Bourguignon__              (o_ Software patents are endangering
()  ASCII ribbon against html email //\ the computer industry all around
/\  and Microsoft attachments.      V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100  2001:my($f)=`fortune`;  http://petition.eurolinux.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]