SlideShare a Scribd company logo
1 of 46
Agenda
•   Project Structure
•   Design Patterns & Architecture
•   Storing Data
•   Coding Conventions
What main design pattern does
Apple recommend for
structuring
your iOS projects?
Model-View-Controller
                   Controller
            Update
                   Coordination            Changes




                    Changes       Update
    Model   Data                               View
                                               Display
Default Project




                  • Notice Classes is a
                    catch-all default
                    ‘’bucket’’ for code
MVC Formatted Project
• Remove references
• Create class folders
  in Finder
  •   AppDelegate
  •   Controllers
  •   Helpers
  •   Models
• Drag into Xcode
According to Apple, should the
model, view or controller be used
to capture events?
Roles & Responsibilities
• Model
  • Data/Algorithms/Networking
  • Most of your custom code lives here
• View
  • Display/Event Capture/Visual Appeal
  • Don’t try to reinvent UIKit, use it
• Controller
  • Coordination/Delegation/Odd Jobs
  • Transitions, Startup/Shutdown
Is this a good pattern & why?




        Update
Don’t cut out the controller!
  Avoid bi-directional messaging

 Reject
 Delay
Validate


                       Update



                 •   Network Access
                      • Multiple
                        Choices
                      • Commit
Is this a good pattern & why?
Loose Coupling

• Don’t skip MVC layers when messaging
  • Use controllers to coordinate messages
• Don’t mix MVC roles in one object
  • Don’t gather too much work in one place
• Don’t declare data in your view classes
  • Maintenance nightmare
  • You can display data in a view, just don’t store it
What are three of the design
patterns used to communicate
between the model, view &
controller?
Communication Between Objects

    Target-Action                    Notification               Delegation
   Reuse controls without           Broadcast changes             Control reuse
       subclassing                                                     “Yes”




   « When tapped, call this
         method »                       « Software keyboard        “End Editing?”
-setTarget:(id)target action:(SEL)action…about to appear! »     UIKit (UIScrollView, ect)
                                       NSNotificationCenter         Will/Did/Should
                                                              -(void)scrollViewDidZoom:
How do you create a custom
controller to split the screen in two
parts?
You Don’t!
    Use the UISplitViewController

• Don’t try to reinvent the wheel
   • UIKit has a lot of the base controls you need
   • Really question whether you need a custom
     control (and if it exists already)
• Don’t misuse framework classes
   • ie Removing views from UIViewControllers
• Don’t try to reinvent the way models, views &
  controllers talk to each other
   • Use delegates & notifications
Is this a good pattern & why?




-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
  if ([scrollView isKindOfClass:[UITableView class]}){
     // do something
  } else {
    // use UIScrollView logic
}
Class checks in delegate methods
Code unmanagable over time - EverythingControllers
Coding horror - iOS version of a GOTO
Correct Approach on
iPad
Parcel out your
controllers
MANDATORY: ALWAYS write/model out your
    iOS app design before coding!
At first, I was like…   But then, it was like…
   (in your brain)           (in the repo)
Creating an MVC diagram of your project
• Means you thought through the architecture
• Means you know how the code will be organized
  physically & logically
• Means you potentially avoided structural bugs
• Easier to validate with the team
• High quality projects & happy clients
What’s the optimal architecture for
a Universal Application?
Optimal Universal App Architecture


    iPhone App                     iPad App


       UI Framework (Views & Controllers)



    Non-UI Framework (Networking & Models)
Photo Sharing Application

                      Data from the model
                      is in both the inspector
                      and in the toolbar
MVC Structure
    Update                Change




             Change




                      Update
What are the six primary ways of
storing data on iOS?
Six Model Options

•   Property Lists
•   Archives
•   Custom Files
•   Server/iCloud/APIs
•   SQLite
•   CoreData
According to Apple, what data should
you store in your App
Defaults/Preferences?
Don’t store data in settings!

• Wrong tool for the job
• App may get rejected
• Settings Panel test
  • On/Off Advanced Features
What should you use for quick storage
of
strings, numbers, arrays, dictionaries, e
ct?
Property Lists.
What should you use to store partial
graphs?
CoreData
•   Modeling Tools
•   Simple save/restore
•   Queries
•   Data Protection
•   Ordered Relationships
•   UIManagedDocument
•   Partial Graphs
•   Undo
•   Incremental Stores
•   ect…
What should you use to include data
with queue-based concurrency in your
app?
CoreData again.
What should you use if you are dealing
with a lot of legacy code or data, or you
need to create an NSObject-based
graph?
Custom Files.
When would you want to use a data
archive?
For easily « serializing »
and « deserializing »
objects in a data file.
What are the two primary features of
SQLite?
Provides Database functionality for iOS apps
Supports Object Relational Mapping
Know Your Data Model Options

•   Property Lists
•   Archives
•   Custom Files
•   Server/iCloud/APIs
•   SQLite
•   CoreData
Coding Conventions
 •   Brace style for if-else
 •   Parenthesis style
 •   Leading underscores
 •   Code indenting
 •   CapitalizationStyle (ie capitalization_style)

 Check out the Google iOS Style guide &
 Apple docs: http://google-
 styleguide.googlecode.com/svn/trunk/objcguide
 .xml
What is KVO?
Key-Value Observing (KVO)
 •   Requires your code to be compliant
 •   Follow style guide
 •   Instrument your own notifications
 •   Automatic Change Notifications for your objects
iOS Coding Best Practices

More Related Content

What's hot

Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven Ankit Gubrani
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for DesignersR. Sosa
 
Angular Web Programlama
Angular Web ProgramlamaAngular Web Programlama
Angular Web ProgramlamaCihan Özhan
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudEberhard Wolff
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSaba Ameer
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAMehak Tawakley
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for javamaheshm1206
 
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaAndroid | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaJAX London
 

What's hot (20)

Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven
 
Ios development
Ios developmentIos development
Ios development
 
Django In The Real World
Django In The Real WorldDjango In The Real World
Django In The Real World
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Angular Web Programlama
Angular Web ProgramlamaAngular Web Programlama
Angular Web Programlama
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
C#.NET
C#.NETC#.NET
C#.NET
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Modern JS with ES6
Modern JS with ES6Modern JS with ES6
Modern JS with ES6
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
 
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaAndroid | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 

Similar to iOS Coding Best Practices

Android architectural components
Android architectural componentsAndroid architectural components
Android architectural componentsMuhammad Ali
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overviewumesh patil
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutAndoni Arroyo
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Adam Mokan
 
iOS apps in Swift
iOS apps in SwiftiOS apps in Swift
iOS apps in SwiftNuno Dias
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
Customizing ERModernLook Applications
Customizing ERModernLook ApplicationsCustomizing ERModernLook Applications
Customizing ERModernLook ApplicationsWO Community
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesUlrich Krause
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcdenemedeniz
 
Real-world Entity Framework
Real-world Entity FrameworkReal-world Entity Framework
Real-world Entity FrameworkLynn Langit
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)Prateek Chauhan
 

Similar to iOS Coding Best Practices (20)

Android architectural components
Android architectural componentsAndroid architectural components
Android architectural components
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overview
 
Module2
Module2Module2
Module2
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012
 
iOS apps in Swift
iOS apps in SwiftiOS apps in Swift
iOS apps in Swift
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Customizing ERModernLook Applications
Customizing ERModernLook ApplicationsCustomizing ERModernLook Applications
Customizing ERModernLook Applications
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
 
Real-world Entity Framework
Real-world Entity FrameworkReal-world Entity Framework
Real-world Entity Framework
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)
 
Php and-mvc
Php and-mvcPhp and-mvc
Php and-mvc
 

More from Jean-Luc David

Implementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS AppsImplementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS AppsJean-Luc David
 
Add Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core MLAdd Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core MLJean-Luc David
 
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)Jean-Luc David
 
Intro to HTTP and Node.js
Intro to HTTP and Node.jsIntro to HTTP and Node.js
Intro to HTTP and Node.jsJean-Luc David
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBJean-Luc David
 
Venture For Canada - Growing Your Startup
Venture For Canada - Growing Your StartupVenture For Canada - Growing Your Startup
Venture For Canada - Growing Your StartupJean-Luc David
 
Venture For Canada - Growth Marketing
Venture For Canada - Growth MarketingVenture For Canada - Growth Marketing
Venture For Canada - Growth MarketingJean-Luc David
 
Venture For Canada - Growth Hacking
Venture For Canada - Growth HackingVenture For Canada - Growth Hacking
Venture For Canada - Growth HackingJean-Luc David
 
Startup Product Management - Analytics
Startup Product Management - AnalyticsStartup Product Management - Analytics
Startup Product Management - AnalyticsJean-Luc David
 
Startup Product Management - Execution
Startup Product Management - ExecutionStartup Product Management - Execution
Startup Product Management - ExecutionJean-Luc David
 
Startup Product Management - Planning
Startup Product Management - PlanningStartup Product Management - Planning
Startup Product Management - PlanningJean-Luc David
 
Building WatchKit Applications
Building WatchKit ApplicationsBuilding WatchKit Applications
Building WatchKit ApplicationsJean-Luc David
 
Confoo Developing for Wearables
Confoo   Developing for WearablesConfoo   Developing for Wearables
Confoo Developing for WearablesJean-Luc David
 
Innovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart SecurityInnovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart SecurityJean-Luc David
 
Developing For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best PracticesDeveloping For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best PracticesJean-Luc David
 
Developing for Wearables
Developing for WearablesDeveloping for Wearables
Developing for WearablesJean-Luc David
 
Ryerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development WorkshopRyerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development WorkshopJean-Luc David
 
Pigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables TorontoPigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables TorontoJean-Luc David
 

More from Jean-Luc David (20)

Implementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS AppsImplementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS Apps
 
Add Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core MLAdd Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core ML
 
Mobile Portfolio
Mobile PortfolioMobile Portfolio
Mobile Portfolio
 
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
 
Intro to HTTP and Node.js
Intro to HTTP and Node.jsIntro to HTTP and Node.js
Intro to HTTP and Node.js
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Venture For Canada - Growing Your Startup
Venture For Canada - Growing Your StartupVenture For Canada - Growing Your Startup
Venture For Canada - Growing Your Startup
 
Venture For Canada - Growth Marketing
Venture For Canada - Growth MarketingVenture For Canada - Growth Marketing
Venture For Canada - Growth Marketing
 
Venture For Canada - Growth Hacking
Venture For Canada - Growth HackingVenture For Canada - Growth Hacking
Venture For Canada - Growth Hacking
 
Startup Product Management - Analytics
Startup Product Management - AnalyticsStartup Product Management - Analytics
Startup Product Management - Analytics
 
Startup Product Management - Execution
Startup Product Management - ExecutionStartup Product Management - Execution
Startup Product Management - Execution
 
Startup Product Management - Planning
Startup Product Management - PlanningStartup Product Management - Planning
Startup Product Management - Planning
 
RightCycle
RightCycleRightCycle
RightCycle
 
Building WatchKit Applications
Building WatchKit ApplicationsBuilding WatchKit Applications
Building WatchKit Applications
 
Confoo Developing for Wearables
Confoo   Developing for WearablesConfoo   Developing for Wearables
Confoo Developing for Wearables
 
Innovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart SecurityInnovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart Security
 
Developing For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best PracticesDeveloping For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best Practices
 
Developing for Wearables
Developing for WearablesDeveloping for Wearables
Developing for Wearables
 
Ryerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development WorkshopRyerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development Workshop
 
Pigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables TorontoPigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables Toronto
 

Recently uploaded

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

iOS Coding Best Practices

  • 1.
  • 2. Agenda • Project Structure • Design Patterns & Architecture • Storing Data • Coding Conventions
  • 3. What main design pattern does Apple recommend for structuring your iOS projects?
  • 4. Model-View-Controller Controller Update Coordination Changes Changes Update Model Data View Display
  • 5. Default Project • Notice Classes is a catch-all default ‘’bucket’’ for code
  • 6. MVC Formatted Project • Remove references • Create class folders in Finder • AppDelegate • Controllers • Helpers • Models • Drag into Xcode
  • 7. According to Apple, should the model, view or controller be used to capture events?
  • 8. Roles & Responsibilities • Model • Data/Algorithms/Networking • Most of your custom code lives here • View • Display/Event Capture/Visual Appeal • Don’t try to reinvent UIKit, use it • Controller • Coordination/Delegation/Odd Jobs • Transitions, Startup/Shutdown
  • 9. Is this a good pattern & why? Update
  • 10. Don’t cut out the controller! Avoid bi-directional messaging Reject Delay Validate Update • Network Access • Multiple Choices • Commit
  • 11. Is this a good pattern & why?
  • 12. Loose Coupling • Don’t skip MVC layers when messaging • Use controllers to coordinate messages • Don’t mix MVC roles in one object • Don’t gather too much work in one place • Don’t declare data in your view classes • Maintenance nightmare • You can display data in a view, just don’t store it
  • 13. What are three of the design patterns used to communicate between the model, view & controller?
  • 14. Communication Between Objects Target-Action Notification Delegation Reuse controls without Broadcast changes Control reuse subclassing “Yes” « When tapped, call this method » « Software keyboard “End Editing?” -setTarget:(id)target action:(SEL)action…about to appear! » UIKit (UIScrollView, ect) NSNotificationCenter Will/Did/Should -(void)scrollViewDidZoom:
  • 15. How do you create a custom controller to split the screen in two parts?
  • 16. You Don’t! Use the UISplitViewController • Don’t try to reinvent the wheel • UIKit has a lot of the base controls you need • Really question whether you need a custom control (and if it exists already) • Don’t misuse framework classes • ie Removing views from UIViewControllers • Don’t try to reinvent the way models, views & controllers talk to each other • Use delegates & notifications
  • 17. Is this a good pattern & why? -(void)scrollViewDidScroll:(UIScrollView *)scrollView { if ([scrollView isKindOfClass:[UITableView class]}){ // do something } else { // use UIScrollView logic }
  • 18. Class checks in delegate methods Code unmanagable over time - EverythingControllers Coding horror - iOS version of a GOTO Correct Approach on iPad Parcel out your controllers
  • 19. MANDATORY: ALWAYS write/model out your iOS app design before coding! At first, I was like… But then, it was like… (in your brain) (in the repo)
  • 20. Creating an MVC diagram of your project • Means you thought through the architecture • Means you know how the code will be organized physically & logically • Means you potentially avoided structural bugs • Easier to validate with the team • High quality projects & happy clients
  • 21.
  • 22. What’s the optimal architecture for a Universal Application?
  • 23. Optimal Universal App Architecture iPhone App iPad App UI Framework (Views & Controllers) Non-UI Framework (Networking & Models)
  • 24. Photo Sharing Application Data from the model is in both the inspector and in the toolbar
  • 25. MVC Structure Update Change Change Update
  • 26. What are the six primary ways of storing data on iOS?
  • 27. Six Model Options • Property Lists • Archives • Custom Files • Server/iCloud/APIs • SQLite • CoreData
  • 28. According to Apple, what data should you store in your App Defaults/Preferences?
  • 29. Don’t store data in settings! • Wrong tool for the job • App may get rejected • Settings Panel test • On/Off Advanced Features
  • 30. What should you use for quick storage of strings, numbers, arrays, dictionaries, e ct?
  • 32. What should you use to store partial graphs?
  • 33. CoreData • Modeling Tools • Simple save/restore • Queries • Data Protection • Ordered Relationships • UIManagedDocument • Partial Graphs • Undo • Incremental Stores • ect…
  • 34. What should you use to include data with queue-based concurrency in your app?
  • 36. What should you use if you are dealing with a lot of legacy code or data, or you need to create an NSObject-based graph?
  • 38. When would you want to use a data archive?
  • 39. For easily « serializing » and « deserializing » objects in a data file.
  • 40. What are the two primary features of SQLite?
  • 41. Provides Database functionality for iOS apps Supports Object Relational Mapping
  • 42. Know Your Data Model Options • Property Lists • Archives • Custom Files • Server/iCloud/APIs • SQLite • CoreData
  • 43. Coding Conventions • Brace style for if-else • Parenthesis style • Leading underscores • Code indenting • CapitalizationStyle (ie capitalization_style) Check out the Google iOS Style guide & Apple docs: http://google- styleguide.googlecode.com/svn/trunk/objcguide .xml
  • 45. Key-Value Observing (KVO) • Requires your code to be compliant • Follow style guide • Instrument your own notifications • Automatic Change Notifications for your objects