Changes between Version 11 and Version 12 of AppleCurrencyConverterBuildingUserInterfaceWithTigerAddClasses

Jan 21, 2008, 10:17:33 PM (13 years ago)



  • AppleCurrencyConverterBuildingUserInterfaceWithTigerAddClasses

    v11 v12  
    2525 4. Now add the action that is triggered when the "Convert" button is pressed: switch to the Actions view and use the "Add" button to add a new action:
     27 [[Image(ibwin-tiger22.jpg)]]
     29 Change the name of the action from "myAction:" to "convert:"
     31 5. Now create an instance of the ConverterController class. In the browser, Right-click the ConverterController class and choose "Instantiate ConverterController". The browser view automatically switches to the Instances view to show you the newly-created instance of ConverterController as a blue box icon. There is a small yellow flag next to the ConverterController instances to show that it has outlets that are not connected to anything. In our final step, we'll create the correct connections for the instance's outlets, which will enable the application to send messages correctly to the objects that implement its behavior.
     33== Converter ==
     35Converter is the model class that implements the actual conversion code. Create a description of the Converter class, and then create an instance of it. Repeat the steps you used to create the !ConverterController class and instance to create a Converter class and instance:
     37 1. Switch to the browser view in the "!CurrencyConverter.nib" window.
     39 2. Control-click NSObject and choose "Subclass NSObject" from the resulting popup menu.
     41 3. Change the name of the newly-created class from "!MyObject" to "Converter".
     43 4. Control-click the "Converter" class and choose "Instantiate Converter" to create an instance of the Converter class.
     45The model class, "Converter", has no outlets or actions, so you don't need to add anything to it before instantiating it. Your code will implement a conversion method, but !InterfaceBuilder doesn't need to know about it; the "convert:" method in your code will know everything it needs to about the "Converter" class. You just need to create the class description and the instance so that your application will start up with the correct objects created and connected.
     47== Connecting the Outlets ==
     49The final step in setting up the user interface is establishing connections between the outlets and objects in the interface, so that messages are sent from the user interface to the correct objects.
     51 1.
    2953[AppleCurrencyConverter Start] [AppleCurrencyConverterBuildingUserInterfaceWithTigerEnableTabbing Previous]