SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04Spy Seat
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patternsallanh0526
 
Spring boot
Spring bootSpring boot
Spring bootsdeeg
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & ArchitectureMassimo Oliviero
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guidelineDhananjaysinh Jhala
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewShahed Chowdhuri
 
Service mesh(istio) monitoring
Service mesh(istio) monitoringService mesh(istio) monitoring
Service mesh(istio) monitoringJeong-Ho Na
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 

Mais procurados (20)

Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Architecting iOS Project
Architecting iOS ProjectArchitecting iOS Project
Architecting iOS Project
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
Service mesh(istio) monitoring
Service mesh(istio) monitoringService mesh(istio) monitoring
Service mesh(istio) monitoring
 
Angular 8
Angular 8 Angular 8
Angular 8
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 

Semelhante a 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
 

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.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
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

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