2. The Model-View-Controller Paradigm
• Model-View-Controller (MVC) is a very logical
way of dividing the code that makes up a GUI-
based application.
• The MVC pattern divides all functionality into
three distinct categories:
– Model: The classes that hold your application’s data.
– View: Made up of the windows, controls, and other
elements that the user can see and interact with.
– Controller: The code that binds together the model
and view. It contains the application logic that decides
how to handle the user’s inputs.
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 2
3. Looking at the View Controller
• The Button Fun folder should contain four
source code files (the ones that end in .h or .m)
and a single nib file.
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 3
4. Looking at the View Controller
• The controller class called BIDViewController is
responsible for managing our application’s
view.
• contents of the BIDViewController header file:
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 4
5. Outlets and Actions
• A controller class can refer to objects in a nib
file by using a special kind of property called
an outlet.
• interface objects in nib file can be set up to
trigger special methods in controller class.
These special methods are known as action
methods.
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 5
6. Outlets
• Outlets are special Objective-C class
properties that are declared using the
keyword IBOutlet.
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 6
7. Actions
• Actions are methods that are declared with a
special return type, IBAction, which tells
Interface Builder that this method can be
triggered by a control in a nib file.
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 7
12. Buttons and Action Method
8) Header file should now look like this:
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 12
13. Buttons and Action Method
9) Impelementation file added a method stub
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 13
14. Label and Outlet
• Adding outlet to label
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 14
15. Label and Outlet
• header file after adding outlet
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 15
16. Action Method
Take the title of the button
Put the title in a string
Equal the string to the label
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 16
17. Application Delegate
• Objects that take responsibility for doing
certain tasks on behalf of another object.
• Every iOS application has one, and only one.
Eng. Abdulrazzaq Alnajjar iabdulrazzaq@outlook.com 17