Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

7. Outlets und Aktionen > 7.11 Ein weiteres Outlet hinzufügen

7.11 Ein weiteres Outlet hinzufügen

Mir gefällt der sich wiederholende Code in der Methode applicationDidFinishLaunching: und im Wahr-Zweig der if-Anweisung von changeGreeting: nicht. Wir setzen die Hintergrundfarbe und den Inhalt des Textfelds zweimal auf den gleichen Wert. Ich möchte daher changeGreeting: aus applicationDidFinishLaunching: heraus aufrufen.

Erkennen Sie das Problem dabei?

Wer soll dabei der sender sein? Wie bekommt changeGreeting: ein Handle auf den Button, wenn es nicht als Reaktion auf einen Button-Klick aufgerufen wird?

Lassen Sie uns ein Outlet für den Button hinzufügen:

Outlets/HelloWorldPro6/HelloWorldProAppDelegate.h

   #import <Cocoa/Cocoa.h>

   @interface HelloWorldProAppDelegate : NSObject <NSApplicationDelegate> {
       NSWindow *window;
       NSTextField *textField;
▸     NSButton *button;
       BOOL isPersonalized;
 }

   

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint