SlideShare a Scribd company logo
Downloaded from: justpaste.it/8q2oq
iOS Actions and Outlets
Here we will learn iOS actions and outlets in swift with examples using Xcode editor and how to use iOS outlets &
actions (IBoutlets and IBActions) in swift with examples.
iOS Actions & Outlets
In iOS Outlets and Actions are basically the property symbol of IBoutlets and IBActions where IB called Interface
Builder and the developer should aware that both IBActions and Outlets are the user interface elements.
If you have some knowledge about object-oriented programming, we can say that the outlet is basically the
reference object and action is the method that is useful to perform some type of actions.
To more information visit:ios app development course.
Syntax of iOS Actions & Outlets
Following is the syntax of using iOS Actions and Outlets in applications.
@IBOutlet weak var labeltxt: UILabel!
@IBAction func buttonaction(sender: AnyObject) {
labeltxt.text = "Hello"
}
If you observe the above syntax we used “@IBOutlet” to add reference of label control and we used “@IBAction” to
add button click action to change label control text.
Now we will see how to use iOS Actions and Outlets features in iOS applications with example.
iOS Actions & Outlets Example
To use iOS Actions and Outlets feature in iOS Applications we will create a simple application for that open the
Xcode Editor from /Applications folder directory. Once we open Xcode the welcome window will open like as
shown below. In the welcome window click on the second option “Create a new Xcode Project” or choose
File à New à Project.
After selecting “Create a new Xcode project” a new window will open in that we need to choose a template.
The new Xcode window will contain several built-in app templates to implement the common types of iOS apps like
page-based apps, tab-based apps, games, table-view apps, etc. These templates are having a pre-configured
interface and source code files.
For this iOS Actions and Outlets example, we will use the most basic template “Single View Application”. To
select this one, Go to the iOS section on the left side à select Application à In the main area of dialog select
“Single View Application” and then click on the next button like as shown below.
After click Next we will get a window like as shown below in this, we need to mention project name and other
details for our application.
Product Name: “iOS Actions & Outlets”
The name whatever we enter in the Product Name section will be used for the project and app.
Organization Name: “Tutlane”
You can enter the name of your organization or your own name or you can leave it as blank.
Organization Identifier: “com.developersociety”
Enter your organization identifier in case if you don't have any organization identifier enter com.example.
Bundle Identifier: This value will generate automatically based on the values we entered in the Product Name and
Organization Identifier.
Language: “Swift”
Select language type as “Swift” because we are going to develop applications using swift.
Devices: “Universal”
Choose Devices options as Universal it means that one application is for all Apple devices in case if you have any
specific requirement to run an app only for iPad then you can choose the iPad option to make your application
restricted to run only on iPad devices.
Use Core Data: Unselected
This option is used for database operations. In case if you have any database related operations in your
application select this option otherwise unselect the option.
Include Unit Tests: Unselected
In case if you need unit tests for your application then select this option otherwise unselect it.
Include UI Tests: Unselected
In case if you need UI tests for your application then select this option otherwise unselect it.
Once you finished entering all the options then click on Next button like as shown below
Once we click on the Next button new dialog will open in that we need to select the location to save our project.
Once you select the location to save project then click on Create button like as shown below
After click on the Create button, the Xcode will create and open a new project. In our
project, Main.storyboard and ViewController.swift are the main files that we used to design the app user
interface and to maintain source code.
Main.storyboard - Its visual interface editor and we will use this file to design our app user interface
ViewController.swift - It contains the source code of our application and we use this file to write any code related
to our app.
Now in project select Main.storyboard file, the Xcode will open visual interface editor like as shown below.
Now select ViewController.Swift file in your project that view will be like as shown below.
Add Controls to StoryBoard File in iOS
Now we will add controls to our application for that open Object Library. The Object Library will appear at the
bottom of Xcode on the right side. In case if you don't find Object library, click on the button which is at the third
position from the left in the library selector bar like as shown below. (Alternatively, you can choose
View à Utilities à Show Object Library).
As we discussed our user interface will be in Main.storyboard file so open Main.storyboard file. Now in Object
library search for the label in Filter field then drag and drop the label into Main.storyboard ViewController same
way drag and drop the button control in ViewController like as shown below.
Connect UI Controls to Code
If we want to implement any functionality for UI controls, we need to map UI controls to the code
in ViewController.swift.
Now we will map our controls to ViewController.swift file for that we need to use Assistant editor in Xcode.
Open the Xcode editor in the assistant mode for that click on the overlap circle button in Xcode toolbar at top right
side like as shown below
Now press the Ctrl button in keyboard and drag the controls from your canvas to the code display
in ViewController.swift file like as shown below.
Once you drag the controls from viewcontroller to code in ViewController.swift file now write code in @IBAction to
change the label text when we click on the button. Once we make required changes our ViewController.swift file
should be like as shown below
// ViewController.swift
// iOS Actions & Outlets
//
// Created by Tutlane on 14/08/2016.
// Copyright © 2016 Tutlane. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var labeltxt: UILabel!
@IBAction func buttonaction(sender: AnyObject) {
labeltxt.text = "Hello"
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Now we will run and check the output of the application. To run the application, select the required simulator (Here
we selected iPhone 6s Plus) and click on Play button, located at the top-left corner of the Xcode toolbar like as
shown below.
Output of iOS Actions & Outlets App
Following is the result of the iOS Actions and Outlets app. Once we run the application click on button it will change
the label text. The button performs the action for the label to change its outlet text.
To more information visit:ios online training

More Related Content

What's hot

Industrial Training report on java
Industrial  Training report on javaIndustrial  Training report on java
Industrial Training report on java
Softvision Info Solutions Private Limited
 
Internship on web development
Internship on web developmentInternship on web development
Internship on web development
Rajendra Kandel
 
Vb.net class notes
Vb.net class notesVb.net class notes
Vb.net class notes
priyadharshini murugan
 
CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19
Gobinath Subramaniam
 
Android app ppt
Android app pptAndroid app ppt
Android app ppt
ADI ADARSH
 
Internship report
Internship reportInternship report
Internship report
Sabana Maharjan
 
Java questions for viva
Java questions for vivaJava questions for viva
Java questions for viva
Vipul Naik
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Interface specification
Interface specificationInterface specification
Interface specification
maliksiddique1
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
ADEEBANADEEM
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Net
rishisingh190
 
College Management System project
College Management System projectCollege Management System project
College Management System project
Manish Kushwaha
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
srs for railway reservation system
 srs for railway reservation system srs for railway reservation system
srs for railway reservation system
khushi kalaria
 
Token, Pattern and Lexeme
Token, Pattern and LexemeToken, Pattern and Lexeme
Token, Pattern and Lexeme
A. S. M. Shafi
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Domain Modeling
Domain ModelingDomain Modeling
Domain Modeling
Harsh Jegadeesan
 
Data Designs (Software Engg.)
Data Designs (Software Engg.)Data Designs (Software Engg.)
Data Designs (Software Engg.)
Arun Shukla
 
Asp.net file types
Asp.net file typesAsp.net file types
Asp.net file types
Siddhesh Palkar
 
Core Java Training report
Core Java Training reportCore Java Training report
Core Java Training report
Sumit Kumar Sharma
 

What's hot (20)

Industrial Training report on java
Industrial  Training report on javaIndustrial  Training report on java
Industrial Training report on java
 
Internship on web development
Internship on web developmentInternship on web development
Internship on web development
 
Vb.net class notes
Vb.net class notesVb.net class notes
Vb.net class notes
 
CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19
 
Android app ppt
Android app pptAndroid app ppt
Android app ppt
 
Internship report
Internship reportInternship report
Internship report
 
Java questions for viva
Java questions for vivaJava questions for viva
Java questions for viva
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Interface specification
Interface specificationInterface specification
Interface specification
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Net
 
College Management System project
College Management System projectCollege Management System project
College Management System project
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
srs for railway reservation system
 srs for railway reservation system srs for railway reservation system
srs for railway reservation system
 
Token, Pattern and Lexeme
Token, Pattern and LexemeToken, Pattern and Lexeme
Token, Pattern and Lexeme
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Domain Modeling
Domain ModelingDomain Modeling
Domain Modeling
 
Data Designs (Software Engg.)
Data Designs (Software Engg.)Data Designs (Software Engg.)
Data Designs (Software Engg.)
 
Asp.net file types
Asp.net file typesAsp.net file types
Asp.net file types
 
Core Java Training report
Core Java Training reportCore Java Training report
Core Java Training report
 

Similar to Ios actions and outlets

I phone first app ducat
I phone first app ducatI phone first app ducat
I phone first app ducat
Pragati Singh
 
Exploring iTools
Exploring iToolsExploring iTools
Exploring iTools
www.netgains.org
 
Getting started with android studio
Getting started with android studioGetting started with android studio
Getting started with android studio
Reham Maher El-Safarini
 
08 10-2013 gtu projects - develop final sem gtu project in i phone
08 10-2013 gtu projects - develop final sem gtu project in i phone08 10-2013 gtu projects - develop final sem gtu project in i phone
08 10-2013 gtu projects - develop final sem gtu project in i phoneTOPS Technologies
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
Chandrakant Divate
 
IOS Swift language 1st Tutorial
IOS Swift language 1st TutorialIOS Swift language 1st Tutorial
IOS Swift language 1st Tutorial
Hassan A-j
 
iPhone application development training day 1
iPhone application development training day 1iPhone application development training day 1
iPhone application development training day 1Shyamala Prayaga
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
Amr Elghadban (AmrAngry)
 
Basic iOS Training with SWIFT - Part 4
Basic iOS Training with SWIFT - Part 4Basic iOS Training with SWIFT - Part 4
Basic iOS Training with SWIFT - Part 4
Manoj Ellappan
 
Create yourfirstandroidapppdf
Create yourfirstandroidapppdfCreate yourfirstandroidapppdf
Create yourfirstandroidapppdfmurad3003
 
Coding Lesson (iOS for non-developers) by Zakery Kline and Roger Kerse
Coding Lesson (iOS for non-developers) by Zakery Kline and Roger KerseCoding Lesson (iOS for non-developers) by Zakery Kline and Roger Kerse
Coding Lesson (iOS for non-developers) by Zakery Kline and Roger KerseEuropean Innovation Academy
 
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
InnovationM
 
Final NEWS.pdf
Final NEWS.pdfFinal NEWS.pdf
Final NEWS.pdf
RebaMaheen
 
Final NewsApp.pdf
Final NewsApp.pdfFinal NewsApp.pdf
Final NewsApp.pdf
RebaMaheen
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
Dhaval Kaneria
 

Similar to Ios actions and outlets (20)

I phone first app ducat
I phone first app ducatI phone first app ducat
I phone first app ducat
 
Exploring iTools
Exploring iToolsExploring iTools
Exploring iTools
 
CI & CD- mobile application
CI & CD- mobile applicationCI & CD- mobile application
CI & CD- mobile application
 
CI & CD- mobile application
CI & CD- mobile applicationCI & CD- mobile application
CI & CD- mobile application
 
Getting started with android studio
Getting started with android studioGetting started with android studio
Getting started with android studio
 
08 10-2013 gtu projects - develop final sem gtu project in i phone
08 10-2013 gtu projects - develop final sem gtu project in i phone08 10-2013 gtu projects - develop final sem gtu project in i phone
08 10-2013 gtu projects - develop final sem gtu project in i phone
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
IOS Swift language 1st Tutorial
IOS Swift language 1st TutorialIOS Swift language 1st Tutorial
IOS Swift language 1st Tutorial
 
iPhone application development training day 1
iPhone application development training day 1iPhone application development training day 1
iPhone application development training day 1
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
Twitter trends
Twitter trendsTwitter trends
Twitter trends
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 
Basic iOS Training with SWIFT - Part 4
Basic iOS Training with SWIFT - Part 4Basic iOS Training with SWIFT - Part 4
Basic iOS Training with SWIFT - Part 4
 
Create yourfirstandroidapppdf
Create yourfirstandroidapppdfCreate yourfirstandroidapppdf
Create yourfirstandroidapppdf
 
Coding Lesson (iOS for non-developers) by Zakery Kline and Roger Kerse
Coding Lesson (iOS for non-developers) by Zakery Kline and Roger KerseCoding Lesson (iOS for non-developers) by Zakery Kline and Roger Kerse
Coding Lesson (iOS for non-developers) by Zakery Kline and Roger Kerse
 
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
 
Final NEWS.pdf
Final NEWS.pdfFinal NEWS.pdf
Final NEWS.pdf
 
Final NewsApp.pdf
Final NewsApp.pdfFinal NewsApp.pdf
Final NewsApp.pdf
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Vb.net ide
Vb.net ideVb.net ide
Vb.net ide
 

More from veeracynixit

Servicenow it management tools
Servicenow it management toolsServicenow it management tools
Servicenow it management tools
veeracynixit
 
Apache avro data serialization framework
Apache avro   data serialization frameworkApache avro   data serialization framework
Apache avro data serialization framework
veeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
veeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
veeracynixit
 
Big data overview of apache hadoop
Big data overview of apache hadoopBig data overview of apache hadoop
Big data overview of apache hadoop
veeracynixit
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
veeracynixit
 
New in Hadoop: You should know the Various File Format in Hadoop.
New in Hadoop: You should know the Various File Format in Hadoop.New in Hadoop: You should know the Various File Format in Hadoop.
New in Hadoop: You should know the Various File Format in Hadoop.
veeracynixit
 
Big data overview of apache hadoop
Big data overview of apache hadoopBig data overview of apache hadoop
Big data overview of apache hadoop
veeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
veeracynixit
 
Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1
veeracynixit
 

More from veeracynixit (10)

Servicenow it management tools
Servicenow it management toolsServicenow it management tools
Servicenow it management tools
 
Apache avro data serialization framework
Apache avro   data serialization frameworkApache avro   data serialization framework
Apache avro data serialization framework
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Big data overview of apache hadoop
Big data overview of apache hadoopBig data overview of apache hadoop
Big data overview of apache hadoop
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
New in Hadoop: You should know the Various File Format in Hadoop.
New in Hadoop: You should know the Various File Format in Hadoop.New in Hadoop: You should know the Various File Format in Hadoop.
New in Hadoop: You should know the Various File Format in Hadoop.
 
Big data overview of apache hadoop
Big data overview of apache hadoopBig data overview of apache hadoop
Big data overview of apache hadoop
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1
 

Recently uploaded

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

Ios actions and outlets

  • 1. Downloaded from: justpaste.it/8q2oq iOS Actions and Outlets Here we will learn iOS actions and outlets in swift with examples using Xcode editor and how to use iOS outlets & actions (IBoutlets and IBActions) in swift with examples. iOS Actions & Outlets In iOS Outlets and Actions are basically the property symbol of IBoutlets and IBActions where IB called Interface Builder and the developer should aware that both IBActions and Outlets are the user interface elements. If you have some knowledge about object-oriented programming, we can say that the outlet is basically the reference object and action is the method that is useful to perform some type of actions. To more information visit:ios app development course. Syntax of iOS Actions & Outlets Following is the syntax of using iOS Actions and Outlets in applications. @IBOutlet weak var labeltxt: UILabel! @IBAction func buttonaction(sender: AnyObject) { labeltxt.text = "Hello" } If you observe the above syntax we used “@IBOutlet” to add reference of label control and we used “@IBAction” to add button click action to change label control text. Now we will see how to use iOS Actions and Outlets features in iOS applications with example. iOS Actions & Outlets Example To use iOS Actions and Outlets feature in iOS Applications we will create a simple application for that open the Xcode Editor from /Applications folder directory. Once we open Xcode the welcome window will open like as shown below. In the welcome window click on the second option “Create a new Xcode Project” or choose File à New à Project.
  • 2. After selecting “Create a new Xcode project” a new window will open in that we need to choose a template. The new Xcode window will contain several built-in app templates to implement the common types of iOS apps like page-based apps, tab-based apps, games, table-view apps, etc. These templates are having a pre-configured interface and source code files. For this iOS Actions and Outlets example, we will use the most basic template “Single View Application”. To select this one, Go to the iOS section on the left side à select Application à In the main area of dialog select “Single View Application” and then click on the next button like as shown below. After click Next we will get a window like as shown below in this, we need to mention project name and other details for our application. Product Name: “iOS Actions & Outlets” The name whatever we enter in the Product Name section will be used for the project and app.
  • 3. Organization Name: “Tutlane” You can enter the name of your organization or your own name or you can leave it as blank. Organization Identifier: “com.developersociety” Enter your organization identifier in case if you don't have any organization identifier enter com.example. Bundle Identifier: This value will generate automatically based on the values we entered in the Product Name and Organization Identifier. Language: “Swift” Select language type as “Swift” because we are going to develop applications using swift. Devices: “Universal” Choose Devices options as Universal it means that one application is for all Apple devices in case if you have any specific requirement to run an app only for iPad then you can choose the iPad option to make your application restricted to run only on iPad devices. Use Core Data: Unselected This option is used for database operations. In case if you have any database related operations in your application select this option otherwise unselect the option. Include Unit Tests: Unselected In case if you need unit tests for your application then select this option otherwise unselect it. Include UI Tests: Unselected In case if you need UI tests for your application then select this option otherwise unselect it. Once you finished entering all the options then click on Next button like as shown below
  • 4. Once we click on the Next button new dialog will open in that we need to select the location to save our project. Once you select the location to save project then click on Create button like as shown below After click on the Create button, the Xcode will create and open a new project. In our project, Main.storyboard and ViewController.swift are the main files that we used to design the app user interface and to maintain source code. Main.storyboard - Its visual interface editor and we will use this file to design our app user interface
  • 5. ViewController.swift - It contains the source code of our application and we use this file to write any code related to our app. Now in project select Main.storyboard file, the Xcode will open visual interface editor like as shown below. Now select ViewController.Swift file in your project that view will be like as shown below. Add Controls to StoryBoard File in iOS Now we will add controls to our application for that open Object Library. The Object Library will appear at the bottom of Xcode on the right side. In case if you don't find Object library, click on the button which is at the third position from the left in the library selector bar like as shown below. (Alternatively, you can choose View à Utilities à Show Object Library).
  • 6. As we discussed our user interface will be in Main.storyboard file so open Main.storyboard file. Now in Object library search for the label in Filter field then drag and drop the label into Main.storyboard ViewController same way drag and drop the button control in ViewController like as shown below. Connect UI Controls to Code If we want to implement any functionality for UI controls, we need to map UI controls to the code in ViewController.swift. Now we will map our controls to ViewController.swift file for that we need to use Assistant editor in Xcode. Open the Xcode editor in the assistant mode for that click on the overlap circle button in Xcode toolbar at top right side like as shown below
  • 7. Now press the Ctrl button in keyboard and drag the controls from your canvas to the code display in ViewController.swift file like as shown below. Once you drag the controls from viewcontroller to code in ViewController.swift file now write code in @IBAction to change the label text when we click on the button. Once we make required changes our ViewController.swift file should be like as shown below // ViewController.swift // iOS Actions & Outlets // // Created by Tutlane on 14/08/2016. // Copyright © 2016 Tutlane. All rights reserved. // import UIKit class ViewController: UIViewController { @IBOutlet weak var labeltxt: UILabel! @IBAction func buttonaction(sender: AnyObject) { labeltxt.text = "Hello" } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } Now we will run and check the output of the application. To run the application, select the required simulator (Here we selected iPhone 6s Plus) and click on Play button, located at the top-left corner of the Xcode toolbar like as
  • 8. shown below. Output of iOS Actions & Outlets App Following is the result of the iOS Actions and Outlets app. Once we run the application click on button it will change the label text. The button performs the action for the label to change its outlet text. To more information visit:ios online training