SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances (20)

Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
 
Angular 6 Form Validation with Material
Angular 6 Form Validation with MaterialAngular 6 Form Validation with Material
Angular 6 Form Validation with Material
 
iOS Architectures
iOS ArchitecturesiOS Architectures
iOS Architectures
 
Web api
Web apiWeb api
Web api
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
ASP.MVC Training
ASP.MVC TrainingASP.MVC Training
ASP.MVC Training
 
Spring Security
Spring SecuritySpring Security
Spring Security
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
C sharp
C sharpC sharp
C sharp
 
Flutter
FlutterFlutter
Flutter
 
Android MVVM
Android MVVMAndroid MVVM
Android MVVM
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Top 11 Mobile App Development Frameworks
Top 11 Mobile App Development FrameworksTop 11 Mobile App Development Frameworks
Top 11 Mobile App Development Frameworks
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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