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

Hour 8. Creating Interactive Application... > Manipulating Controls at Runtime wit...

Manipulating Controls at Runtime with Code

As you saw in the preceding example, the one prerequisite for manipulating a control at runtime is the need for a pointer to that control. You can either get that pointer by creating an instance of the control manually (we haven’t covered this, so don’t worry about that scenario) or when Cocoa creates an instance of the control for you by reading from an Interface Builder file and you have created a connection between the control and your outlet.

You’ve already seen how to perform simple control manipulations in the preceding sample. The following line of code, taken from the previous section, shows how to set the string value of the label (which is really an instance of NSTextField) at runtime:

resultsLabel.stringValue = [NSString stringWithFormat:@"%d%%", odds];


  

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