You are previewing High Performance iOS Apps.
O'Reilly logo
High Performance iOS Apps

Book Description

Now that more people spend more time interacting with mobile apps than with their desktop counterparts, you need to think about your iOS app’s performance the moment you write your first line of code. This practical hands-on guide shows you how. Through specific and concise tips for designing and optimizing your apps, author Gaurav Vaish provides solutions to many common performance scenarios, including reusable code that you can put to work right away.

Table of Contents

  1. Preface
    1. Who Should Read This Book
    2. Why I Wrote This Book
    3. Navigating This Book
    4. Online Resources
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
  2. I. Getting Started
  3. 1. Performance in Mobile Apps
    1. Defining Performance
    2. Performance Metrics
      1. Memory
      2. Power Consumption
      3. Initialization Time
      4. Execution Speed
      5. Responsiveness
      6. Local Storage
      7. Interoperability
      8. Network Condition
      9. Bandwidth
      10. Data Refresh
      11. Multiuser Support
      12. Single Sign-on
      13. Security
      14. Crashes
    3. App Profiling
      1. Sampling
      2. Instrumentation
    4. Measurement
      1. Project and Code Setup
      2. Crash Reporting Setup
      3. Instrumenting Your App
      4. Logging
    5. Summary
  4. II. Core Optimizations
  5. 2. Memory Management
    1. Memory Consumption
      1. Stack Size
      2. Heap Size
    2. Memory Management Model
    3. Autoreleasing Objects
    4. Autorelease Pool Blocks
    5. Automatic Reference Counting
      1. Rules of ARC
    6. Reference Types
      1. Variable Qualifiers
      2. Property Qualifiers
    7. Getting Your Hands Dirty
      1. Photo Model
      2. Storyboard Update
      3. Method Implementations
      4. Output Analysis
    8. Zombies
    9. Rules of Memory Management
    10. Retain Cycles
      1. Rules to Avoid Retain Cycles
      2. Common Scenarios for Retain Cycles
      3. Observers
      4. Returning Errors
    11. Weak Type: id
      1. Solution to the Problem
    12. Object Longevity and Leaks
    13. Singletons
    14. Finding Mystery Retains
    15. Best Practices
    16. Memory Usage in Production
    17. Summary
  6. 3. Energy
    1. CPU
    2. Network
    3. Location Manager and GPS
      1. Optimal Initialization
      2. Turn Off Inessential Features
      3. Use Network Only If Essential
      4. Background Location Services
      5. NSTimers, NSThreads, and Location Services
      6. Restart After App Kill
    4. Screen
      1. Animation
      2. Video Play
      3. Multiple Screens
    5. Other Hardware
    6. Battery Level and State-Aware Code
    7. Profiling for Energy Use
    8. Best Practices
    9. Summary
  7. 4. Concurrent Programming
    1. Threads
    2. The Cost of Threads
      1. Kernel Data Structures
      2. Stack Size
      3. Creation Time
    3. GCD
    4. Operations and Queues
    5. Thread-Safe Code
      1. Atomic Properties
      2. Synchronized Blocks
      3. Locks
      4. Use Reader–Writer Locks for Concurrent Reads and Writes
      5. Use Immutable Entities
      6. Have a Central State Updater Service
      7. State Observers and Notifications
      8. Prefer Async over Sync
    6. Summary
  8. III. iOS Performance
  9. 5. Application Lifecycle
    1. App Delegate
    2. Application Launch
      1. First Launch
      2. Cold Start
      3. Warm Launch
      4. Launch After Upgrade
    3. Push Notifications
      1. Remote Notifications
      2. Local Notifications
    4. Background Fetch
    5. Summary
  10. 6. User Interface
    1. View Controller
      1. View Load
      2. View Hierarchy
      3. View Visibility
    2. View
      1. UILabel
      2. UIButton
      3. UIImageView
      4. UITableView
      5. UIWebView
      6. Custom Views
    3. Auto Layout
    4. Size Classes
    5. New Interaction Features in iOS 8
      1. Interactive Notifications
      2. App Extensions
    6. Summary
  11. 7. Network
    1. Metrics and Measurement
      1. DNS Lookup Time
      2. SSL Handshake Time
      3. Network Type
      4. Latency
      5. Networking API
    2. App Deployment
      1. Servers
      2. Request
      3. Data Format
    3. Tools
      1. Network Link Conditioner
      2. AT&T Application Resource Optimizer
      3. Charles
    4. Summary
  12. 8. Data Sharing
    1. Deep Linking
    2. Pasteboards
    3. Sharing Content
      1. Document Interaction
      2. Activities
    4. iOS 8 Extensions
      1. Configuration for Action and Share Extensions
      2. Action Extensions
      3. Share Extensions
      4. Document Provider Extension
      5. App Groups
    5. Summary
  13. 9. Security
    1. App Access
      1. Anonymous Access
      2. Authenticated Access
    2. Network Security
      1. Use HTTPS
      2. Use Certificate Pinning
    3. Local Storage
    4. Data Sharing
    5. Security and App Performance
    6. Checklist
    7. Summary
  14. IV. Beyond Code
  15. 10. Testing and Release
    1. Test Types
    2. Definitions
    3. Unit Testing
      1. Setup
      2. Writing Unit Tests
      3. Code Coverage
      4. Asynchronous Operations
      5. Xcode 6 Bonus: Performance Unit Tests
      6. Dependency Mocking
      7. Other Frameworks
    4. Functional Testing
      1. Setup
      2. Writing Functional Tests
      3. Project Structure
    5. Dependency Isolation
    6. Testing and Component Design
    7. Continuous Integration and Automation
    8. Best Practices
      1. Performance Testing
    9. Summary
  16. 11. Tools
    1. Accessibility Inspector
      1. Xcode Accessibility Inspector
      2. iOS Accessibility Inspector
    2. Instruments
      1. Using Instruments
      2. Activity Monitor
      3. Allocations
      4. Leaks
      5. Network
      6. Time Profiler
    3. Xcode View Debugger
    4. PonyDebugger
    5. Charles
    6. Summary
  17. 12. Instrumentation and Analytics
    1. Vocabulary
    2. Instrumentation
      1. Planning
      2. Implementation
      3. Deployment
    3. Analytics
    4. Real User Monitoring
      1. Analytics Versus Real User Monitoring
      2. Using RUM
    5. Summary
  18. V. iOS 9
  19. 13. iOS 9
    1. Application Lifecycle
      1. Universal Links
      2. Search
      3. Search Best Practices
    2. User Interface
      1. UIKit Framework
      2. Safari Services Framework
    3. Extensions
      1. Content Blocker Extension
      2. Spotlight Index Extension
    4. App Thinning
      1. Slicing
      2. On Demand Resources
      3. Bitcode
    5. Summary
  20. Index