0% found this document useful (0 votes)
9 views20 pages

Unit 1 Swift. Playground Class Presentataion

This document introduces basic programming concepts like variables, data types, classes, objects, inheritance, and the model-view-controller architecture. It explains that variables store values, common data types include integers, floats, Booleans and strings, and classes define attributes and behaviors that objects are instantiated from using inheritance. The model-view-controller pattern separates an app into independent sections for data, user interface display, and logic/control flow.

Uploaded by

sujathaumcet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views20 pages

Unit 1 Swift. Playground Class Presentataion

This document introduces basic programming concepts like variables, data types, classes, objects, inheritance, and the model-view-controller architecture. It explains that variables store values, common data types include integers, floats, Booleans and strings, and classes define attributes and behaviors that objects are instantiated from using inheritance. The model-view-controller pattern separates an app into independent sections for data, user interface display, and logic/control flow.

Uploaded by

sujathaumcet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Mobile Programming

Unit 1
Introduction to Programming
 Building Blocks
 Variables
 Integer
 Float
 Boolean
 Class
 Object
Basic Building Blocks
 Variables
 Bank account balance, it shows the current amount of money you have
available. Your bank account may be $100 at the beginning of the month,
and $350 on your payday.
 This is an example of a variable.
 A variable is a representation of a value.
 Variables come in many different shapes and sizes.
 Different types of variables hold different types of values.
 Numbers, letters, words, true, false, or even a custom car.

 Integer
 An integer is a whole number, a number without any decimal places,
positive or negative: Example -10, 0, 100, 21031
 An integer could be used for the number of stars for a movie review, a
house’s street address, or the score for a sports team.
Basic Building Blocks
 Float
 need to be more precise with a value.
 In the case of currency, a decimal place is used to keep track of the cents on a
dollar $10.51
 A decimal-based variable is called a float. Float is short for floating point,
another name for a decimal place

 Boolean
 Respond with either Yes or No.
 cannot respond with 7, $103.45, or “Banana.”
 Yes or No variable is referred to as a Boolean.
 Similar to a light switch—they are either on or off,true or false; there is no in-
between value
Basic Building Blocks
 String
 Name - collection of letters that form a set of words
 Eg:"SteveDerico"
 A string is used to represent characters strung together to make words
and sentences.
 A string can hold a series of letters, numbers, and symbols. Strings are
surrounded by a pair of quotes. For example:
 "Steve is cool."
 "Where is the ball?"
 "Go Giants
Basic Building Blocks
 Classes
 Different types of automobiles –different –few core
characteristics
 wheels, an engine, and brakes
 Core characteristics are called attributes.
 purpose and provides value to the consumer.
 A car can drive, honk, brake, and steer. Basic methods are
available in every car.
 Without these methods, it would not be a car. These core methods
are called behaviors.
 Designing a new car, a blueprint would be a good place to start.
 Blueprint is a document that serves as a template for building
something. Blueprint defines the attributes and behaviors of the car
Basic Building Blocks

Car blueprint

Has Wheels Class is a blueprint for a virtual object.


Has Engine
Has Brakes Class defines the required attributes and
Can Drive Forward behaviors.
Can Stop
Can Steer Left and Right
Just like a cookie cutter, a class can produce
endless objects from a single
blueprint.
 Has –attributes
 Can -Behaviors
Basic Building Blocks

Green station wagon


 Objects Wheels- Standard
Engine- Diesel
 Attributes make them unique Brakes -Standard
 Each of these cars is an object from the car class. Acceleration -Poor
Stopping -Great
 Object is the product produced by a class. Steering -Fair
 An object has the attributes and behaviors from its
class, in this case, the car class.
 Instance and object are commonly used as synonyms
Red sports car
 combination of the values with their associated Wheels Big
Engine Big
attributes is what makes an object unique. Brakes Performance
Acceleration Great
 Humans have hundreds of attributes and thousands Stopping Great
of possible values for each attribute. Steering Great
Basic Building Blocks

 Methods
 computer processes a list of steps to achieve a task. This
list of steps is called a method.
 A method is a collection of code to complete a specific
task
 Example –Cooking Process
Basic Building Blocks

Car
 Inheritance Wheels Standard
Engine Standard
 passing down of attributes and behaviors from
Brakes Standard
parent to child is called inheritance. Can Drive Forward
 Inheritance is the ability for a class to extend or Can Stop
override functionality from a parent class. Can Steer Left and Right
 Example - class you created was the parent of SUV
the SUV class. Wheels Mud
 SUV class will inherit all the attributes and Engine V8
behaviors of the car class. SUV will also be Brakes Standard
Drive System All-Wheel
able to add its own attributes and behaviors.
Can Drive Forward
Can Stop
Can Steer Left and Righ
Can Drive Uphill
Can Tow a Boat
Basic Building Blocks

 Override the inherited attributes.


 Overriding is the ability to change how an attribute or behavior
works for a class.
 This allows the SUV class to customize and control the inherited
attributes and behaviors the SUV class has an engine, but it is a V8
engine.
 The child class is often referred to as a subclass of the parent class.
In this case, the SUV class is a subclass of the car class.
Model View Controller
 Model-View- Controller architecture helps to
organize your code into three distinct parts.
l
Model View Controller
Model
 Portion of code has to do with the data.
 For example, consider creating an application
that stores all your friends’ contact
information.
 Model portion would hold the phone numbers
and addresses.
 Containing zeros and ones
l
Model View Controller
View
 Code contains all the code related to the user
interface.

 view is like a picture frame; it holds and


displays a picture, but it doesn’t know what
picture it is displaying

 View code should not be connected to the


content it is displaying.

 This way, if the interface is changed, it doesn’t


affect the content.
l
Model View Controller
Controller
 All the logic and decision-making code.
 Like a traffic cop; he directs the others where to go.
 It talks to the view and the model directly.
 The controller responds to taps on the screens, pulls
data from the model, and tells the view what to
display.
 The model and view never speak directly to each
other. All communication goes through the
controller.
first app
Xcode
 Open up Xcode.
 If you don’t see Xcode in your Dock,
 click the Spotlight search icon in the
upper-right corner of your screen. Type
in Xcode and click Top Hit
 Click “Create a New Xcode Project.”
 Next, you will see the project template dialog
 Select Single View Application and click Next.
 fill in details for your new project

You might also like