[Top][All Lists]

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

Re: One Question

Subject: Re: One Question
Date: Fri, 27 Apr 2001 02:31:38 +0800

  Sorry for misleading.
  I set Black as a Instance Method.
  I put the source code in:
  You can just check the Red methond in AppDelegate.m
  and Black method in ImageWindow.m
  I use AppDelegate to create a instance of ImageWindow,
  then use ImageWindow *keyWin = [NSApp keyWindow] 
  to get the key instance of ImageWindow.
  Then I set a menu to use Red instance method in Appdelegate.
  And this Red method should call Black instace method in keyWin.
  But the error shows the NSWindow can't recongnize Black.

  I can use another way to solve this problem,
  but I just feel strange because this way should work.
  Thanx a lot


"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





        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/

Discuss-gnustep mailing list

e-Direct Corp. http://www.edirect168.com 
provides best quality & service FREE E-MAIL

reply via email to

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