《高性能iOS应用》PDF下载

  • 购买积分:14 如何计算积分?
  • 作  者:Gaurav Vaish著
  • 出 版 社:南京:东南大学出版社
  • 出版年份:2017
  • ISBN:9787564170028
  • 页数:446 页
图书介绍:准备好构建性能超群的移动应用了吗?如果你是一个具有应用开发经验的iOS开发人员,这本实用指南提供的建议和最佳实践将帮助你解决许多常见的性能问题。你将学到如何设计并优化iOS应用以提供流畅的体验,甚至是在网络信号很差和内存有限的情况下。如今挑剔的用户想要快速和灵敏的应用,并且还不能消耗系统资源。在本书中,作者 GauravVaish从一个工程师的角度,演示了编写优化代码的多种方法,这些可重用的Objective-C代码都是你可以立即使用的。行动起来,创作高性能的原生iOS应用,令它们真正地从众多应用中脱颖而出。

Part Ⅰ.Getting Started 3

1.Performance in Mobile Apps 3

Defining Performance 4

Performance Metrics 4

Memory 4

Power Consumption 4

Initialization Time 5

Execution Speed 5

Responsiveness 6

Local Storage 6

Interoperability 7

Network Condition 8

Bandwidth 9

Data Refresh 9

Multiuser Support 9

Single Sign-on 11

Security 11

Crashes 11

App Profiling 12

Sampling 12

Instrumentation 12

Measurement 12

Project and Code Setup 13

Crash Reporting Setup 14

Instrumenting Your App 15

Logging 20

Summary 23

Part Ⅱ.Core Optimizations 27

2.Memory Management 27

Memory Consumption 28

Stack Size 28

Heap Size 29

Memory Management Model 32

Autoreleasing Objects 34

Autorelease Pool Blocks 35

Automatic Reference Counting 39

Rules of ARC 41

Reference Types 42

Variable Qualifiers 43

Property Qualifiers 44

Getting Your Hands Dirty 45

Photo Model 45

Storyboard Update 46

Method Implementations 47

Output Analysis 49

Zombies 50

Rules of Memory Management 51

Retain Cycles 52

Rules to Avoid Retain Cycles 53

Common Scenarios for Retain Cycles 54

Observers 67

Returning Errors 70

Weak Type:id 71

Solution to the Problem 72

Object Longevity and Leaks 74

Singletons 74

Finding Mystery Retains 77

Best Practices 78

Memory Usage in Production 79

Summary 80

3.Energy 81

CPU 81

Network 83

Location Manager and GPS 87

Optimal Initialization 89

Turn Off Inessential Features 90

Use Network Only If Essential 92

Background Location Services 92

NSTimers,NSThreads,and Location Services 93

Restart After App Kill 93

Screen 94

Animation 94

Video Play 94

Multiple Screens 94

Other Hardware 99

Battery Level and State-Aware Code 100

Profiling for Energy Use 102

Best Practices 103

Summary 106

4.Concurrent Programming 107

Threads 107

The Cost of Threads 108

Kernel Data Structures 108

Stack Size 108

Creation Time 109

GCD 109

Operations and Queues 110

Thread-Safe Code 112

Atomic Properties 112

Synchronized Blocks 113

Locks 115

Use Reader-Writer Locks for Concurrent Reads and Writes 121

Use Immutable Entities 123

Have a Central State Updater Service 128

State Observers and Notifications 134

Prefer Async over Sync 139

Summary 141

Part Ⅲ.iOS Performance 145

5.Application Lifecycle 145

App Delegate 145

Application Launch 147

First Launch 150

Cold Start 158

Warm Launch 166

Launch After Upgrade 169

Push Notifications 169

Remote Notifications 169

Local Notifications 173

Background Fetch 174

Summary 177

6.User Interface 179

View Controller 181

View Load 183

View Hierarchy 184

View Visibility 187

View 189

UILabel 191

UIButton 192

UIImageView 194

UITableView 195

UIWebView 199

Custom Views 203

Auto Layout 210

Size Classes 212

New Interaction Features in iOS 8 217

Interactive Notifications 217

App Extensions 219

Summary 222

7.Network 223

Metrics and Measurement 223

DNS Lookup Time 224

SSL Handshake Time 226

Network Type 227

Latency 234

Networking API 237

App Deployment 238

Servers 238

Request 239

Data Format 240

Tools 241

Network Link Conditioner 241

AT&T Application Resource Optimizer 243

Charles 245

Summary 248

8.Data Sharing 251

Deep Linking 252

Pasteboards 258

Sharing Content 261

Document Interaction 262

Activities 271

iOS 8 Extensions 274

Configuration for Action and Share Extensions 276

Action Extensions 277

Share Extensions 278

Document Provider Extension 282

App Groups 287

Summary 289

9.Security 291

App Access 292

Anonymous Access 292

Authenticated Access 294

Network Security 299

Use HTTPS 299

Use Certificate Pinning 300

Local Storage 305

Data Sharing 312

Security and App Performance 312

Checklist 313

Summary 315

Part Ⅳ.Beyond Code 315

10.Testingand Release 319

Test Types 319

Definitions 320

Unit Testing 321

Setup 321

Writing Unit Tests 323

Code Coverage 325

Asynchronous Operations 330

Xcode 6 Bonus:Performance Unit Tests 331

Dependency Mocking 333

Other Frameworks 337

Functional Testing 338

Setup 339

Writing Functional Tests 341

Project Structure 344

Dependency Isolation 345

Testing and Component Design 347

Continuous Integration and Automation 349

Best Practices 351

Performance Testing 352

Summary 355

11.Tools 357

Accessibility Inspector 358

Xcode Accessibility Inspector 359

iOS Accessibility Inspector 360

Instruments 363

Using Instruments 364

Activity Monitor 367

Allocations 369

Leaks 372

Network 374

Time Profiler 374

Xcode View Debugger 375

PonyDebugger 377

Charles 382

Summary 388

12.Instrumentation and Analytics 389

Vocabulary 390

Instrumentation 391

Planning 392

Implementation 395

Deployment 398

Analytics 398

Real User Monitoring 399

Analytics Versus Real User Monitoring 399

Using RUM 399

Summary 400

Part Ⅴ.iOS9 401

13.iOS 9 403

Application Lifecycle 403

Universal Links 404

Search 407

Search Best Practices 412

User Interface 414

UIKit Framework 414

Safari Services Framework 418

Extensions 421

Content Blocker Extension 422

Spotlight Index Extension 426

App Thinning 426

Slicing 427

On Demand Resources 427

Bitcode 431

Summary 432

Index 433