SlideShare a Scribd company logo
1 of 46
UNDERSTANDING
iOS Specifics
OVERVIEW
• Lesson 1: Introductions
• Lesson 2: iOS specifics
• Lesson 3: Data Model
• Lesson 4: Logic (Controller) & Interface
LESSON 2: IOS SPECIFICS
• Hour 1: Anatomy of an App
• Hour 2: View
• Hour 3: Different types of applications with
Xcode
ANATOMY OF AN APP
ANATOMY OF AN APP
• UIApplication
• AppDelegate
• App Launch Cycle
• Controller object that maintains app event loop
• High-level app behaviours
‣ Interace orientation changes
‣ Suspend incoming touch events
‣ Proximity sensing of user’s face
‣ etc…
• When app is launched, UIApplicationMain function is called
• One single instance of UIApplication is created
• We can call the UIApplication object through the sharedApplication class method
• UIApplicationMain is made available by importing UIKit framework
UIApplication
UIApplication
main.m
UIApplication
Access UIApplication from anywhere
UIApplication *application;
application = [UIApplication sharedApplication];
UIApplication
Practical usage
// Hide status bar when app is launched
// AppDelegate.m application:didFinishLaunchingWithOptions:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
UIApplication
TakeNotes-Info.plist
UIApplication
TakeNotes-Info.plist
• Custom object created at App launch time, usually by
UIApplicationMain function
• Main purpose is to handle transitions between states (the state of
your App)
‣ Not running
‣ Inactive
‣ Active
‣ Background
‣ Suspended
AppDelegate
• State Transitions are usually handled by corresponding call to methods of our app delegate object
‣ application:willFinishLaunchingWithOptions:
(execute code at run time)
‣ application:didFinishLaunchingWithOptions:
(perform final initialisations before app is displayed to user)
‣ applicationDidBecomeActive:
(app becomes the foreground app)
‣ applicationWillResignActive:
(lets us know our app is transiting away from being foreground app)
‣ applicationDidEnterBackground:
(lets us know our app is running in background and may be suspended at any time)
‣ applicationWillEnterForeground:
(lets us know our app is moving out of background and back into foreground but not yet active)
‣ applicationWillTerminate:
(lets us know our app is being terminated. This method is not called if app is suspended)
AppDelegate
App Launch Cycle
• UIApplication object
• AppDelegate
• Data model objects (and documents)
• View controller objects
• UIWindow object
• View, control and layer objects
Anatomy of an App
• Representation of what your app does (using custom
classes, subclass from NSObject for example)
• Spaceship game app will have Spaceship class,
TakeNotes app will have Note class, Painting app
could define a Image class
• Can subclass from UIDocument as well if we want to
define a document-based data model
• Other possibilities if using CoreData
(NSManagedObject) or Realm.io (RLMObject)
Data model objects
ANATOMY OF AN APP
• Manages the presentation on screen
• A view controller manages a single view and
its collection of sub-views
• When presented, the view controller makes
its views visible by installing them in app’s
window
• Uses base class UIViewController
View Controller
• Co-ordinates presentation of one or more views on
screen
• Most apps have only one window, which presents
content on main screen; but apps may have additional
window for content displayed on external screen
• To change content of app, use view controller to
change views displayed in corresponding window.
Never replace window.
• Besides hosting views, windows work with
UIWindow object
UIWindow object
ANATOMY OF AN APP
UIWindow
ANATOMY OF AN APP
View
• View and controls and layer objects provide the visual representation of
our app
• They are subclassed from UIView
• View: object that draws content in a designated rectangular area and
responds to events in that area.
• Controls: “special” view which implements commonly used interfaces
like buttons, text fields, toggle switches etc
• We generally use the standard classes provided by UIKit framework to
create our views and controls
• If we want to, we can subclass from UIView directly to create our
custom visual element (object)
View
• We can control our views from storyboard
• Storyboards allow us to set view objects we
want on a view
• Storyboards also allow us to connect view
objects to our code
View
View
View Controller
DetailViewController.h
@property (weak, nonatomic) IBOutlet UITextView *tView;
DetailViewController.m
@synthesize tView;
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
self.tView.text = [self.detailItem description];
}
}
View to View Controller
View to View Controller
Some Explanations?
@property
A declared property so the values given to that property can be set and
accessed easily
@synthesize
If we declare a property name (e.g. tView), the default setter name is _tView
(setter is where we “set” the value(s) pertaining to the tView object). So we write
@synthesize tView in our implementation file so that we can call its setter by the
same name
IBOutlet
Identifier used to identify a property so that Interface Builder can synchronise the
display and connection of outlets with Xcode.
Some Explanations?
@property (weak, nonatomic)
atomic versus nonatomic as property attributes
• properties are atomic by default
• this means that a value is always fully retrieved by getter method or fully set by setter
method, even if accessors are called by different threads
• we use nonatomic property attribute to specify that our synthesised accessors simply
set or return a value directly, with no guarantees about what happens to this value if
it is accessed simultaneously from different threads, so it’s usually faster to access a
nonatomic property than an atomic one and we can combine a synthesized setter
with our own getter implementation
Some Explanations?
@property (weak, nonatomic)
weak versus strong as property attributes
• In example diagram, XYZPerson object owns the two string properties for
firstName and lastName. firstName and lastName is available in our app’s
memory as long as XYZPerson is in the memory. In other words, they are
strongly referenced by the XYZPerson object
Some Explanations?
@property (weak, nonatomic)
weak versus strong as property attributes
• we use weak attribute when working with groups of
interconnected objects. In our example, the tView property
can be controlled by other logic in future, so it is not a one-way
relationship.
Extra Explanations
IBOutlet vs IBAction
@interface Controller
// links to TextField UI object
@property (weak, nonatomic) IBOutlet id textField;
// e.g. called when button pushed
- (IBAction)doAction:(id)sender;
Different App Templates
• Master-Detail Application
• Tabbed Application
• OpenGL Game
• Utility Application
• Page-based Application
• Single View Application
• SpriteKit Game
• Empty Application
Different App Templates
Master-Detail App
Tabbed App
OpenGL Game App
Utility App
Page-based App
Single View App
SpriteKit Game App
Empty App
WHAT’S NEXT
• Lesson 1: Introductions
• Lesson 2: iOS specifics
• Lesson 3: Data Model
• Lesson 4: Logic (Controller) & Interface

More Related Content

What's hot

In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
WO Community
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
DataArt
 

What's hot (20)

Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
 
MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
 
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
 
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
React Native Introduction: Making Real iOS and Android Mobile App By JavaScriptReact Native Introduction: Making Real iOS and Android Mobile App By JavaScript
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
 
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor ExtensionsConnect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
 
iOS viper presentation
iOS viper presentationiOS viper presentation
iOS viper presentation
 
MVS: An angular MVC
MVS: An angular MVCMVS: An angular MVC
MVS: An angular MVC
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
 
React-Native Lecture 11: In App Storage
React-Native Lecture 11: In App StorageReact-Native Lecture 11: In App Storage
React-Native Lecture 11: In App Storage
 
Automation strategies for agile testing Gaurav bansal
Automation strategies for agile testing  Gaurav bansalAutomation strategies for agile testing  Gaurav bansal
Automation strategies for agile testing Gaurav bansal
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
 
Getting Started with Javascript
Getting Started with JavascriptGetting Started with Javascript
Getting Started with Javascript
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 

Similar to iOS Beginners Lesson 2

iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
NascentDigital
 
The Spring Framework: A brief introduction to Inversion of Control
The Spring Framework:A brief introduction toInversion of ControlThe Spring Framework:A brief introduction toInversion of Control
The Spring Framework: A brief introduction to Inversion of Control
VisualBee.com
 

Similar to iOS Beginners Lesson 2 (20)

iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Ios development 2
Ios development 2Ios development 2
Ios development 2
 
iOS Development (Part 2)
iOS Development (Part 2)iOS Development (Part 2)
iOS Development (Part 2)
 
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
 
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: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App Development
 
Meetup - Getting Started with MVVM Light for WPF - 11 may 2019
Meetup  - Getting Started with MVVM Light for WPF - 11 may 2019Meetup  - Getting Started with MVVM Light for WPF - 11 may 2019
Meetup - Getting Started with MVVM Light for WPF - 11 may 2019
 
Android architecture
Android architecture Android architecture
Android architecture
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Mobile Application Development class 006
Mobile Application Development class 006Mobile Application Development class 006
Mobile Application Development class 006
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
Ui 5
Ui   5Ui   5
Ui 5
 
Objects and classes in Visual Basic
Objects and classes in Visual BasicObjects and classes in Visual Basic
Objects and classes in Visual Basic
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
Reactotron - A Debugging Agent
Reactotron -  A Debugging AgentReactotron -  A Debugging Agent
Reactotron - A Debugging Agent
 
The Spring Framework: A brief introduction to Inversion of Control
The Spring Framework:A brief introduction toInversion of ControlThe Spring Framework:A brief introduction toInversion of Control
The Spring Framework: A brief introduction to Inversion of Control
 
Delegateless Coordinator
Delegateless CoordinatorDelegateless Coordinator
Delegateless Coordinator
 

More from Calvin Cheng

More from Calvin Cheng (11)

FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/SovrinFOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
 
Hashgraph as Code
Hashgraph as CodeHashgraph as Code
Hashgraph as Code
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
 
So, you want to build a Bluetooth Low Energy device?
So, you want to build a Bluetooth Low Energy device?So, you want to build a Bluetooth Low Energy device?
So, you want to build a Bluetooth Low Energy device?
 
Fabric
FabricFabric
Fabric
 
Ladypy 01
Ladypy 01Ladypy 01
Ladypy 01
 
zhng your vim
zhng your vimzhng your vim
zhng your vim
 
Django101 geodjango
Django101 geodjangoDjango101 geodjango
Django101 geodjango
 
Saving Gaia with GeoDjango
Saving Gaia with GeoDjangoSaving Gaia with GeoDjango
Saving Gaia with GeoDjango
 
Agile Apps with App Engine
Agile Apps with App EngineAgile Apps with App Engine
Agile Apps with App Engine
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 

iOS Beginners Lesson 2

  • 2. OVERVIEW • Lesson 1: Introductions • Lesson 2: iOS specifics • Lesson 3: Data Model • Lesson 4: Logic (Controller) & Interface
  • 3. LESSON 2: IOS SPECIFICS • Hour 1: Anatomy of an App • Hour 2: View • Hour 3: Different types of applications with Xcode
  • 5. ANATOMY OF AN APP • UIApplication • AppDelegate • App Launch Cycle
  • 6. • Controller object that maintains app event loop • High-level app behaviours ‣ Interace orientation changes ‣ Suspend incoming touch events ‣ Proximity sensing of user’s face ‣ etc… • When app is launched, UIApplicationMain function is called • One single instance of UIApplication is created • We can call the UIApplication object through the sharedApplication class method • UIApplicationMain is made available by importing UIKit framework UIApplication
  • 8. UIApplication Access UIApplication from anywhere UIApplication *application; application = [UIApplication sharedApplication];
  • 9. UIApplication Practical usage // Hide status bar when app is launched // AppDelegate.m application:didFinishLaunchingWithOptions: [[UIApplication sharedApplication] setStatusBarHidden:YES];
  • 12. • Custom object created at App launch time, usually by UIApplicationMain function • Main purpose is to handle transitions between states (the state of your App) ‣ Not running ‣ Inactive ‣ Active ‣ Background ‣ Suspended AppDelegate
  • 13. • State Transitions are usually handled by corresponding call to methods of our app delegate object ‣ application:willFinishLaunchingWithOptions: (execute code at run time) ‣ application:didFinishLaunchingWithOptions: (perform final initialisations before app is displayed to user) ‣ applicationDidBecomeActive: (app becomes the foreground app) ‣ applicationWillResignActive: (lets us know our app is transiting away from being foreground app) ‣ applicationDidEnterBackground: (lets us know our app is running in background and may be suspended at any time) ‣ applicationWillEnterForeground: (lets us know our app is moving out of background and back into foreground but not yet active) ‣ applicationWillTerminate: (lets us know our app is being terminated. This method is not called if app is suspended) AppDelegate
  • 15.
  • 16.
  • 17. • UIApplication object • AppDelegate • Data model objects (and documents) • View controller objects • UIWindow object • View, control and layer objects Anatomy of an App
  • 18. • Representation of what your app does (using custom classes, subclass from NSObject for example) • Spaceship game app will have Spaceship class, TakeNotes app will have Note class, Painting app could define a Image class • Can subclass from UIDocument as well if we want to define a document-based data model • Other possibilities if using CoreData (NSManagedObject) or Realm.io (RLMObject) Data model objects
  • 20. • Manages the presentation on screen • A view controller manages a single view and its collection of sub-views • When presented, the view controller makes its views visible by installing them in app’s window • Uses base class UIViewController View Controller
  • 21. • Co-ordinates presentation of one or more views on screen • Most apps have only one window, which presents content on main screen; but apps may have additional window for content displayed on external screen • To change content of app, use view controller to change views displayed in corresponding window. Never replace window. • Besides hosting views, windows work with UIWindow object
  • 23. ANATOMY OF AN APP UIWindow
  • 24. ANATOMY OF AN APP View
  • 25. • View and controls and layer objects provide the visual representation of our app • They are subclassed from UIView • View: object that draws content in a designated rectangular area and responds to events in that area. • Controls: “special” view which implements commonly used interfaces like buttons, text fields, toggle switches etc • We generally use the standard classes provided by UIKit framework to create our views and controls • If we want to, we can subclass from UIView directly to create our custom visual element (object) View
  • 26. • We can control our views from storyboard • Storyboards allow us to set view objects we want on a view • Storyboards also allow us to connect view objects to our code View
  • 27. View
  • 28. View Controller DetailViewController.h @property (weak, nonatomic) IBOutlet UITextView *tView; DetailViewController.m @synthesize tView; - (void)configureView { // Update the user interface for the detail item. if (self.detailItem) { self.tView.text = [self.detailItem description]; } }
  • 29. View to View Controller
  • 30. View to View Controller
  • 31. Some Explanations? @property A declared property so the values given to that property can be set and accessed easily @synthesize If we declare a property name (e.g. tView), the default setter name is _tView (setter is where we “set” the value(s) pertaining to the tView object). So we write @synthesize tView in our implementation file so that we can call its setter by the same name IBOutlet Identifier used to identify a property so that Interface Builder can synchronise the display and connection of outlets with Xcode.
  • 32. Some Explanations? @property (weak, nonatomic) atomic versus nonatomic as property attributes • properties are atomic by default • this means that a value is always fully retrieved by getter method or fully set by setter method, even if accessors are called by different threads • we use nonatomic property attribute to specify that our synthesised accessors simply set or return a value directly, with no guarantees about what happens to this value if it is accessed simultaneously from different threads, so it’s usually faster to access a nonatomic property than an atomic one and we can combine a synthesized setter with our own getter implementation
  • 33. Some Explanations? @property (weak, nonatomic) weak versus strong as property attributes • In example diagram, XYZPerson object owns the two string properties for firstName and lastName. firstName and lastName is available in our app’s memory as long as XYZPerson is in the memory. In other words, they are strongly referenced by the XYZPerson object
  • 34. Some Explanations? @property (weak, nonatomic) weak versus strong as property attributes • we use weak attribute when working with groups of interconnected objects. In our example, the tView property can be controlled by other logic in future, so it is not a one-way relationship.
  • 35. Extra Explanations IBOutlet vs IBAction @interface Controller // links to TextField UI object @property (weak, nonatomic) IBOutlet id textField; // e.g. called when button pushed - (IBAction)doAction:(id)sender;
  • 37. • Master-Detail Application • Tabbed Application • OpenGL Game • Utility Application • Page-based Application • Single View Application • SpriteKit Game • Empty Application Different App Templates
  • 46. WHAT’S NEXT • Lesson 1: Introductions • Lesson 2: iOS specifics • Lesson 3: Data Model • Lesson 4: Logic (Controller) & Interface