SlideShare a Scribd company logo
iOS Development (Part II)
COMPILED BY: ASIM RAIS SIDDIQUI
Goals of the Lecture
 Use of TextField, Label, Sliders and Switch buttons
 Handling ActionSheet and Alerts
 Application Delegates
 Handling ActionSheet and Alerts
 Application Delegates
 UIApplication Delegates
 View Controllers
 Life Cycle of Application & Methods
 ARC
Application Delegate
 A delegate is an object that acts on behalf of, or in coordination
with, another object when that object encounters an event in a
program. The delegating object is often a responder object—that is,
an object inheriting from NSResponder in AppKit or UIResponder in
UIKit—that is responding to a user event. The delegate is an object
that is delegated control of the user interface for that event, or is at
least asked to interpret the event in an application-specific manner.
 These objects are designed to fulfill a specific role in a generic
fashion; a window object in the AppKit framework, for example,
responds to mouse manipulations of its controls and handles such
things as closing, resizing, and moving the physical window.
UIApplication & Delegates
View Controllers
View controllers are a vital link
between an app’s data and its visual
appearance. Whenever an iOS app
displays a user interface, the
displayed content is managed by a
view controller or a group of view
controllers coordinating with each
other. Therefore, view controllers
provide the skeletal framework on
which you build your apps.
iOS provides many built-in view
controller classes to support standard
user interface pieces, such as
navigation and tab bars. As part of
developing an app, you also
implement one or more custom
controllers to display the content
specific to your app.
Life Cycle &
Methods
Note:
 When Apple switched the default compiler from GCC to LLVM
recently, it stopped being necessary to declare instance variables
for properties. If LLVM finds a property without a matching instance
variable, it will create one automatically.
ARC
 Automatic Reference Counting (ARC) is a new feature of the
Objective-C language, introduced with iOS 5, that makes your life
much easier.
 It’s no longer necessary to release objects. Well, that’s not entirely true.
It is necessary, but the LLVM 3.0 compiler that Apple started shipping
with iOS 5 is so smart that it will release objects for us, using a new
feature called Automatic Reference Counting, or ARC, to do the heavy
lifting. That means no more dealloc methods, and no more worrying
about calling release or autorelease.
 ARC is very cool, but it’s not magic. You should still understand the basic
rules of memory management in Objective-C to avoid getting in
trouble with ARC. To brush up on the Objective-C memory
management contract, read Apple’s Memory Management
Programming Guide at this URL:
 https://developer.apple.com/library/ios/#documentation/Cocoa/Con
cep tual/MemoryMgmt/
Subclassing
 It is an important feature of any object-oriented programming
environment and the iPhone SDK is no exception to this rule. Subclassing
allows us to create a new class by deriving from an existing class and then
extending the functionality. In so doing we get all the functionality of the
parent class combined with the ability to extend the new class with
additional methods and properties.
Subclassing
@interface Superclass : NSObject {
int v;
}
- (void)initV;
@end
@implementation Superclass
- (void)initV {
v = 20;
}
@end
@interface Subclass : Superclass {
int w;
}
- (void)displayVars;
@end
@implementation Subclass
- (void)initW {
w = 50;
}
- (void)displayVars {
NSLog(@"v is %d, w is %d", v, w);
}
@end
Subclassing
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Subclass *sub = [[Subclass alloc] init];
[sub initV]; // Inherited method & ivar
[sub initW]; // Own method & ivar
[sub displayVars];// Inherited method [sub release];
[pool drain];
return 0;
}
Output:
v is 20, w is 50
Action Sheet and Alert
 Action sheets are used to force the user to make a choice between
two or more items. The action sheet comes up from the bottom of
the screen and displays a series of buttons. Users are unable to
continue using the application until they have tapped one of the
buttons. Action sheets are often used to confirm a potentially
dangerous or irreversible action such as deleting an object.
 Alerts appear as a blue, rounded rectangle in the middle of the
screen. Just like action sheets, alerts force users to respond before
they are allowed to continue using the application. Alerts are usually
used to inform the user that something important or out of the
ordinary has occurred. Unlike action sheets, alerts may be
presented with only a single button, although you have the option
of presenting multiple buttons if more than one response is
appropriate.
Conforming to the Action Sheet
Delegate Method
 In order for our controller class to act as the delegate for an action
sheet, it needs to conform to a protocol called
UIActionSheetDelegate.
 @interface BIDViewController : UIViewController
<UIActionSheetDelegate>
 Other parameter allow you to add more buttons
 E.g otherButtonTitles:@"Foo", @"Bar", nil
Switching Views
 presentModalViewController and presentViewController
 Other different techniques to switch views
 - view overlapping
 - navigation controller
Navigation Controller
 The main tool you’ll use to build hierarchical applications
is UINavigationController. UINavigationController is similar
to UITabBarController in that it manages, and swaps in
and out, multiple content views. The main difference
between the two is that UINavigationController is
implemented as a stack, which makes it well suited to
working with hierarchies.
 A stack is a commonly used data structure that works on
the principle of last in, first out.
Stack
 A computer stack follows the same rules:
 When you add an object to a stack, it’s called a push. You push an
object onto the stack.
 The first object you push onto the stack is called the base of the
stack.
 The last object you pushed onto the stack is called the top of the
stack
 (at least until it is replaced by the next object you push onto the stack).
 When you remove an object from the stack, it’s called a pop.
When you pop an object off the stack, it’s always the last one you
pushed onto the stack. Conversely, the first object you push onto the
stack will always be the last one you pop off the stack.
Setting Up the Navigation Controller
 Add property in main app delegate file
@property (strong, nonatomic) UINavigationController *navController;
Then implement
self.navController = [[UINavigationController alloc]
initWithRootViewController:self.viewController];
User push or pop, when needed:
[self.navigationController pushViewController:foo animated:YES];
TableViews
 First, what’s a Table View in iPhone app? Table View is one of the
common UI elements in iOS apps. Most apps, in some ways, make
use of Table View to display list of data.
 The best example is the built-in Phone app. Your contacts are
displayed in a Table View.
 Another example is the Mail app. It uses Table View to display your
mail boxes and emails. Not only designed for showing textual data,
Table View allows you to present the data in the form of images. The
built-in Video and YouTube app are great examples for the usage.
UITableViewDelegate and
UITableViewDataSource
 The UITableView, the actual class behind the Table View, is designed to be
flexible to handle various types of data. You may display a list of countries or
contact names. Or like this example, we’ll use the table view to present a list of
recipes. So how do you tell UITableView the list of data to display?
UITableViewDataSource is the answer. It’s the link between your data and the
table view. The UITableViewDataSource protocol declares two required
methods (tableView:cellForRowAtIndexPath and
tableView:numberOfRowsInSection) that you have to implement. Through
implementing these methods, you tell Table View how many rows to display and
the data in each row.
 UITableViewDelegate, on the other hand, deals with the appearance of the
UITableView. Optional methods of the protocols let you manage the height of a
table row, configure section headings and footers, re-order table cells, etc. We
do not change any of these methods in this example. Let’s leave them for the
next tutorial.
 numberOfSectionsInTableView
 numberOfRowsInSection
 cellForRowAtIndexPath
 didSelectRowAtIndexPath
Tab Bar App
 No more windows.xib file
 Add ThirdViewController subclassing UIViewController
 Add DetailViewController subclassing UIViewController
 #import "ThirdViewController.h"
 Create new class object
 ThirdViewController *navController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
 Create Navigation instance
 UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:navController];
@class Directive
 The @class directive sets up a forward reference to another class. It
tells the compiler that the named class exists, so when the compiler
gets to, say an @property directive line, no additional information is
needed, it assumes all is well and plows ahead.
@Classs
Vs
#Import

More Related Content

What's hot

Android appwidget
Android appwidgetAndroid appwidget
Android appwidgetKrazy Koder
 
Chapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action barChapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action bar
Kalluri Vinay Reddy
 
Chapter 2 lesson-2 styling the action bar
Chapter 2 lesson-2 styling the action barChapter 2 lesson-2 styling the action bar
Chapter 2 lesson-2 styling the action bar
Kalluri Vinay Reddy
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceDive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
Oleksii Prohonnyi
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & Layouts
Vijay Rastogi
 
Calc app
Calc appCalc app
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
Dr. Ramkumar Lakshminarayanan
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application development
Zoltán Váradi
 
Android Tutorials - Powering with Selection Widget
Android Tutorials - Powering with Selection WidgetAndroid Tutorials - Powering with Selection Widget
Android Tutorials - Powering with Selection Widget
Prajyot Mainkar
 
Angular JS, steal the idea
Angular JS, steal the ideaAngular JS, steal the idea
Angular JS, steal the idea
Scott Lee
 
SharePoint Framework y React
SharePoint Framework y ReactSharePoint Framework y React
SharePoint Framework y React
SUGES (SharePoint Users Group España)
 
UI5con 2017 - Create your own UI5 controls – what’s coming up
UI5con 2017 - Create your own UI5 controls – what’s coming upUI5con 2017 - Create your own UI5 controls – what’s coming up
UI5con 2017 - Create your own UI5 controls – what’s coming up
Andreas Kunz
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
Amr Salman
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
Raghubir Singh
 
Create your own control - UI5Con
Create your own control - UI5ConCreate your own control - UI5Con
Create your own control - UI5Con
Wouter Lemaire
 
Binding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseBinding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseKranthi Kumar
 
Learnings for Accessibility for iOS Platform
Learnings for Accessibility for iOS PlatformLearnings for Accessibility for iOS Platform
Learnings for Accessibility for iOS Platform
Tasneem Sayeed
 

What's hot (20)

Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
 
Chapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action barChapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action bar
 
Chapter 2 lesson-2 styling the action bar
Chapter 2 lesson-2 styling the action barChapter 2 lesson-2 styling the action bar
Chapter 2 lesson-2 styling the action bar
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceDive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & Layouts
 
Android course (lecture2)
Android course (lecture2)Android course (lecture2)
Android course (lecture2)
 
Calc app
Calc appCalc app
Calc app
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application development
 
Android Tutorials - Powering with Selection Widget
Android Tutorials - Powering with Selection WidgetAndroid Tutorials - Powering with Selection Widget
Android Tutorials - Powering with Selection Widget
 
Les16
Les16Les16
Les16
 
Angular JS, steal the idea
Angular JS, steal the ideaAngular JS, steal the idea
Angular JS, steal the idea
 
SharePoint Framework y React
SharePoint Framework y ReactSharePoint Framework y React
SharePoint Framework y React
 
UI5con 2017 - Create your own UI5 controls – what’s coming up
UI5con 2017 - Create your own UI5 controls – what’s coming upUI5con 2017 - Create your own UI5 controls – what’s coming up
UI5con 2017 - Create your own UI5 controls – what’s coming up
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
Create your own control - UI5Con
Create your own control - UI5ConCreate your own control - UI5Con
Create your own control - UI5Con
 
Binding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseBinding,context mapping,navigation exercise
Binding,context mapping,navigation exercise
 
Learnings for Accessibility for iOS Platform
Learnings for Accessibility for iOS PlatformLearnings for Accessibility for iOS Platform
Learnings for Accessibility for iOS Platform
 

Similar to iOS Development (Part 2)

Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
Dhaval Kaneria
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
Palakjaiswal43
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1Hussain Behestee
 
Java lab lecture 2
Java  lab  lecture 2Java  lab  lecture 2
Java lab lecture 2
vishal choudhary
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
Amr Elghadban (AmrAngry)
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
Amit Saxena
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
Monir Zzaman
 
Hello Android
Hello AndroidHello Android
Hello Android
Trong Dinh
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
vishal choudhary
 
Activity
ActivityActivity
Activity
NikithaNag
 
Activity
ActivityActivity
Activity
roopa_slide
 
Activity
ActivityActivity
Activity
NikithaNag
 
Activity
ActivityActivity
Activity
roopa_slide
 
Intro to ios - init by SLOHacks
Intro to ios - init by SLOHacksIntro to ios - init by SLOHacks
Intro to ios - init by SLOHacks
Randy Scovil
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid drawinfo_zybotech
 
Ch12. graphical user interfaces
Ch12. graphical user interfacesCh12. graphical user interfaces
Ch12. graphical user interfaces
Arslan Karamat
 
Csharp
CsharpCsharp
Csharp
vinayabburi
 
android activity
android activityandroid activity
android activityDeepa Rani
 

Similar to iOS Development (Part 2) (20)

Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Swift
SwiftSwift
Swift
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Java lab lecture 2
Java  lab  lecture 2Java  lab  lecture 2
Java lab lecture 2
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Hello Android
Hello AndroidHello Android
Hello Android
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Intro to ios - init by SLOHacks
Intro to ios - init by SLOHacksIntro to ios - init by SLOHacks
Intro to ios - init by SLOHacks
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
Ch12. graphical user interfaces
Ch12. graphical user interfacesCh12. graphical user interfaces
Ch12. graphical user interfaces
 
Csharp
CsharpCsharp
Csharp
 
android activity
android activityandroid activity
android activity
 

More from Asim Rais Siddiqui

Understanding Blockchain Technology
Understanding Blockchain TechnologyUnderstanding Blockchain Technology
Understanding Blockchain Technology
Asim Rais Siddiqui
 
IoT Development - Opportunities and Challenges
IoT Development - Opportunities and ChallengesIoT Development - Opportunities and Challenges
IoT Development - Opportunities and Challenges
Asim Rais Siddiqui
 
iOS Memory Management
iOS Memory ManagementiOS Memory Management
iOS Memory Management
Asim Rais Siddiqui
 
iOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI ComponentsiOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI Components
Asim Rais Siddiqui
 
iOS Development (Part 1)
iOS Development (Part 1)iOS Development (Part 1)
iOS Development (Part 1)
Asim Rais Siddiqui
 
Introduction to Objective - C
Introduction to Objective - CIntroduction to Objective - C
Introduction to Objective - C
Asim Rais Siddiqui
 
Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#Asim Rais Siddiqui
 
Introduction to iOS Development
Introduction to iOS DevelopmentIntroduction to iOS Development
Introduction to iOS DevelopmentAsim Rais Siddiqui
 

More from Asim Rais Siddiqui (8)

Understanding Blockchain Technology
Understanding Blockchain TechnologyUnderstanding Blockchain Technology
Understanding Blockchain Technology
 
IoT Development - Opportunities and Challenges
IoT Development - Opportunities and ChallengesIoT Development - Opportunities and Challenges
IoT Development - Opportunities and Challenges
 
iOS Memory Management
iOS Memory ManagementiOS Memory Management
iOS Memory Management
 
iOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI ComponentsiOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI Components
 
iOS Development (Part 1)
iOS Development (Part 1)iOS Development (Part 1)
iOS Development (Part 1)
 
Introduction to Objective - C
Introduction to Objective - CIntroduction to Objective - C
Introduction to Objective - C
 
Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#
 
Introduction to iOS Development
Introduction to iOS DevelopmentIntroduction to iOS Development
Introduction to iOS Development
 

Recently uploaded

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
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
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
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
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
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
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
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
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
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
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
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
 
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
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 

Recently uploaded (20)

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
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...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
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 -...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
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...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
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
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
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
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
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...
 
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...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 

iOS Development (Part 2)

  • 1. iOS Development (Part II) COMPILED BY: ASIM RAIS SIDDIQUI
  • 2. Goals of the Lecture  Use of TextField, Label, Sliders and Switch buttons  Handling ActionSheet and Alerts  Application Delegates  Handling ActionSheet and Alerts  Application Delegates  UIApplication Delegates  View Controllers  Life Cycle of Application & Methods  ARC
  • 3. Application Delegate  A delegate is an object that acts on behalf of, or in coordination with, another object when that object encounters an event in a program. The delegating object is often a responder object—that is, an object inheriting from NSResponder in AppKit or UIResponder in UIKit—that is responding to a user event. The delegate is an object that is delegated control of the user interface for that event, or is at least asked to interpret the event in an application-specific manner.  These objects are designed to fulfill a specific role in a generic fashion; a window object in the AppKit framework, for example, responds to mouse manipulations of its controls and handles such things as closing, resizing, and moving the physical window.
  • 5. View Controllers View controllers are a vital link between an app’s data and its visual appearance. Whenever an iOS app displays a user interface, the displayed content is managed by a view controller or a group of view controllers coordinating with each other. Therefore, view controllers provide the skeletal framework on which you build your apps. iOS provides many built-in view controller classes to support standard user interface pieces, such as navigation and tab bars. As part of developing an app, you also implement one or more custom controllers to display the content specific to your app.
  • 7. Note:  When Apple switched the default compiler from GCC to LLVM recently, it stopped being necessary to declare instance variables for properties. If LLVM finds a property without a matching instance variable, it will create one automatically.
  • 8. ARC  Automatic Reference Counting (ARC) is a new feature of the Objective-C language, introduced with iOS 5, that makes your life much easier.  It’s no longer necessary to release objects. Well, that’s not entirely true. It is necessary, but the LLVM 3.0 compiler that Apple started shipping with iOS 5 is so smart that it will release objects for us, using a new feature called Automatic Reference Counting, or ARC, to do the heavy lifting. That means no more dealloc methods, and no more worrying about calling release or autorelease.  ARC is very cool, but it’s not magic. You should still understand the basic rules of memory management in Objective-C to avoid getting in trouble with ARC. To brush up on the Objective-C memory management contract, read Apple’s Memory Management Programming Guide at this URL:  https://developer.apple.com/library/ios/#documentation/Cocoa/Con cep tual/MemoryMgmt/
  • 9. Subclassing  It is an important feature of any object-oriented programming environment and the iPhone SDK is no exception to this rule. Subclassing allows us to create a new class by deriving from an existing class and then extending the functionality. In so doing we get all the functionality of the parent class combined with the ability to extend the new class with additional methods and properties.
  • 10. Subclassing @interface Superclass : NSObject { int v; } - (void)initV; @end @implementation Superclass - (void)initV { v = 20; } @end @interface Subclass : Superclass { int w; } - (void)displayVars; @end @implementation Subclass - (void)initW { w = 50; } - (void)displayVars { NSLog(@"v is %d, w is %d", v, w); } @end
  • 11. Subclassing int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Subclass *sub = [[Subclass alloc] init]; [sub initV]; // Inherited method & ivar [sub initW]; // Own method & ivar [sub displayVars];// Inherited method [sub release]; [pool drain]; return 0; } Output: v is 20, w is 50
  • 12. Action Sheet and Alert  Action sheets are used to force the user to make a choice between two or more items. The action sheet comes up from the bottom of the screen and displays a series of buttons. Users are unable to continue using the application until they have tapped one of the buttons. Action sheets are often used to confirm a potentially dangerous or irreversible action such as deleting an object.  Alerts appear as a blue, rounded rectangle in the middle of the screen. Just like action sheets, alerts force users to respond before they are allowed to continue using the application. Alerts are usually used to inform the user that something important or out of the ordinary has occurred. Unlike action sheets, alerts may be presented with only a single button, although you have the option of presenting multiple buttons if more than one response is appropriate.
  • 13. Conforming to the Action Sheet Delegate Method  In order for our controller class to act as the delegate for an action sheet, it needs to conform to a protocol called UIActionSheetDelegate.  @interface BIDViewController : UIViewController <UIActionSheetDelegate>  Other parameter allow you to add more buttons  E.g otherButtonTitles:@"Foo", @"Bar", nil
  • 14. Switching Views  presentModalViewController and presentViewController  Other different techniques to switch views  - view overlapping  - navigation controller
  • 15. Navigation Controller  The main tool you’ll use to build hierarchical applications is UINavigationController. UINavigationController is similar to UITabBarController in that it manages, and swaps in and out, multiple content views. The main difference between the two is that UINavigationController is implemented as a stack, which makes it well suited to working with hierarchies.  A stack is a commonly used data structure that works on the principle of last in, first out.
  • 16. Stack  A computer stack follows the same rules:  When you add an object to a stack, it’s called a push. You push an object onto the stack.  The first object you push onto the stack is called the base of the stack.  The last object you pushed onto the stack is called the top of the stack  (at least until it is replaced by the next object you push onto the stack).  When you remove an object from the stack, it’s called a pop. When you pop an object off the stack, it’s always the last one you pushed onto the stack. Conversely, the first object you push onto the stack will always be the last one you pop off the stack.
  • 17. Setting Up the Navigation Controller  Add property in main app delegate file @property (strong, nonatomic) UINavigationController *navController; Then implement self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; User push or pop, when needed: [self.navigationController pushViewController:foo animated:YES];
  • 18. TableViews  First, what’s a Table View in iPhone app? Table View is one of the common UI elements in iOS apps. Most apps, in some ways, make use of Table View to display list of data.  The best example is the built-in Phone app. Your contacts are displayed in a Table View.  Another example is the Mail app. It uses Table View to display your mail boxes and emails. Not only designed for showing textual data, Table View allows you to present the data in the form of images. The built-in Video and YouTube app are great examples for the usage.
  • 19. UITableViewDelegate and UITableViewDataSource  The UITableView, the actual class behind the Table View, is designed to be flexible to handle various types of data. You may display a list of countries or contact names. Or like this example, we’ll use the table view to present a list of recipes. So how do you tell UITableView the list of data to display? UITableViewDataSource is the answer. It’s the link between your data and the table view. The UITableViewDataSource protocol declares two required methods (tableView:cellForRowAtIndexPath and tableView:numberOfRowsInSection) that you have to implement. Through implementing these methods, you tell Table View how many rows to display and the data in each row.  UITableViewDelegate, on the other hand, deals with the appearance of the UITableView. Optional methods of the protocols let you manage the height of a table row, configure section headings and footers, re-order table cells, etc. We do not change any of these methods in this example. Let’s leave them for the next tutorial.
  • 20.  numberOfSectionsInTableView  numberOfRowsInSection  cellForRowAtIndexPath  didSelectRowAtIndexPath
  • 21. Tab Bar App  No more windows.xib file  Add ThirdViewController subclassing UIViewController  Add DetailViewController subclassing UIViewController  #import "ThirdViewController.h"  Create new class object  ThirdViewController *navController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];  Create Navigation instance  UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:navController];
  • 22. @class Directive  The @class directive sets up a forward reference to another class. It tells the compiler that the named class exists, so when the compiler gets to, say an @property directive line, no additional information is needed, it assumes all is well and plows ahead.

Editor's Notes

  1. It is an important feature of any object-oriented programming environment and the iPhone SDK is no exception to this rule. Subclassing allows us to create a new class by deriving from an existing class and then extending the functionality. In so doing we get all the functionality of the parent class combined with the ability to extend the new class with additional methods and properties.Subclassing is typically used where an existing class exists that does most, but not all, of what you need. By subclassing we get all that existing functionality without having to duplicate it and simply add on the functionality that was missing.We will see an example of subclassing in the context of iPhone development when we start to work with view controllers. The UIKit framework contains a class called the UIViewController. This is a generic view controller from which we will create a subclass so that we can add our own methods and properties.
  2. The next argument is the delegate for the action sheet. The action sheet’s delegate will be notified when a button on that sheet has been tapped. More specifically, the delegate’s actionSheet:didDismissWithButtonIndex: method will be called. By passing self as the delegate parameter, we ensure that our version of actionSheet:didDismissWithButtonIndex: will be called. Why didn’t we just use view, instead of self.view? view is a private instance variable of our parent class UIViewController, which means we can’t access it directly, but instead must use an accessor method.
  3. @class doesn&apos;t import the file, it just says to the compiler &quot;This class exists even though you don&apos;t know about it, don&apos;t warn me if I use it&quot;. #import actually imports the file so you can use all the methods and instance variables. @class is used to save time compiling (importing the whole file makes the compile take more time). You can use #import if you want, it will just take longer for your project to build.