在好例子网,分享、交流、成长!
您当前所在位置:首页Swift 开发实例Swift语言基础 → O'Reilly iOS 15 Programming Fundamentals with Swift pdf

O'Reilly iOS 15 Programming Fundamentals with Swift pdf

Swift语言基础

下载此实例
  • 开发语言:Swift
  • 实例大小:7.50M
  • 下载次数:10
  • 浏览次数:134
  • 发布时间:2022-02-11
  • 实例类别:Swift语言基础
  • 发 布 人:gaalxy
  • 文件格式:.pdf
  • 所需积分:2
 相关标签: Fundamentals Programming swift iOS pdf

实例介绍

【实例简介】O'Reilly iOS 15 Programming Fundamentals with Swift

2021.10最新出版的iOS 15 Swift开发教程, 

Swift 5.5, iOS 15, and Xcode 13


【实例截图】

【核心代码】

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Part I. Language
1. The Architecture of Swift. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Ground of Being 3
Everything Is an Object? 4
Three Flavors of Object Type 6
Variables 6
Functions 8
The Structure of a Swift File 9
Scope and Lifetime 12
Object Members 13
Namespaces 13
Modules 14
Instances 15
Why Instances? 17
The Keyword self 19
Privacy 20
Design 22
2. Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Function Parameters and Return Value 25
Void Return Type and Parameters 29
Function Signature 30
External Parameter Names 30
Overloading 32
iii
Default Parameter Values 33
Variadic Parameters 34
Ignored Parameters 35
Modifiable Parameters 36
Calling Objective-C with Modifiable Parameters 37
Called by Objective-C with Modifiable Parameters 38
Reference Type Modifiable Parameters 39
Function in Function 40
Recursion 40
Function as Value 41
Anonymous Functions 44
Using Anonymous Functions Inline 45
Anonymous Function Abbreviated Syntax 46
Define-and-Call 50
Closures 51
How Closures Improve Code 53
Function Returning Function 54
Closure Setting a Captured Variable 57
Closure Preserving Captured Environment 58
Escaping Closures 59
Capture Lists 60
Curried Functions 62
Function References and Selectors 63
Function Reference Scope 65
Selectors 67
3. Variables and Simple Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Variable Scope and Lifetime 71
Variable Declaration 73
Computed Variable Initialization 77
Computed Variables 78
Computed Properties 79
Property Wrappers 81
Setter Observers 82
Lazy Initialization 83
Singleton 84
Lazy Initialization of Instance Properties 85
Built-In Simple Types 85
Bool 85
Numbers 88
iv | Table of Contents
String 96
Character and String Index 102
Range 106
Tuple 108
Optional 111
4. Object Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Object Type Declarations and Features 125
Initializers 127
Properties 133
Methods 136
Subscripts 139
Nested Object Types 141
Enums 142
Raw Values 143
Associated Values 145
Enum Case Iteration 147
Enum Initializers 148
Enum Properties 149
Enum Methods 150
Why Enums? 152
Structs 153
Struct Initializers 153
Struct Properties 154
Struct Methods 155
Classes 156
Value Types and Reference Types 157
Subclass and Superclass 162
Class Initializers 168
Class Deinitializer 176
Class Properties 176
Static/Class Members 177
Polymorphism 178
Casting 182
Casting Down 183
Type Testing and Casting Down Safely 183
Type Testing and Casting Optionals 185
Bridging to Objective-C 186
Type References 187
From Instance to Type 187
Table of Contents | v
From self to Type 187
Type as Value 191
Summary of Type Terminology 192
Comparing Types 192
Protocols 193
Why Protocols? 194
Adopting a Library Protocol 195
Protocol Type Testing and Casting 197
Declaring a Protocol 197
Protocol Composition 198
Class Protocols 199
Optional Protocol Members 200
Implicitly Required Initializers 202
Expressible by Literal 204
Generics 205
Generic Declarations 208
Type Constraints 210
Explicit Specialization 212
Generic Types and Covariance 213
Associated Type Chains 215
Where Clauses 217
Extensions 220
Extending Protocols 222
Extending Generics 225
Umbrella Types 227
Any 227
AnyObject 229
AnyClass 231
Collection Types 232
Array 232
Dictionary 251
Set 258
OrderedSet and OrderedDictionary 263
5. Flow Control and More. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Flow Control 269
Branching 270
Loops 282
Jumping 288
Privacy 305
vi | Table of Contents
Private and Fileprivate 306
Public and Open 308
Privacy Rules 309
Introspection 309
Operators 310
Memory Management 313
Memory Management of Reference Types 314
Exclusive Access to Value Types 321
Miscellaneous Swift Language Features 323
Synthesized Protocol Implementations 323
Key Paths 326
Instance as Function 329
Dynamic Membership 330
Property Wrappers 332
Custom String Interpolation 337
Reverse Generics 339
Result Builders 341
Result 341
6. Structured Concurrency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Multithreading 344
The Main Thread 344
Background Threads 345
Asynchronous Code 347
Structured Concurrency Syntax 353
async/await 354
Async Contexts 355
Tasks 356
Wrapping a Completion Handler 357
Multiple Concurrent Tasks 361
async let 362
Task Groups 363
Asynchronous Sequences 367
Built-in Asynchronous Sequences 368
Making an Asynchronous Sequence 369
Asynchronous Sequence Methods 370
Actors 370
Actor Isolation 371
Actor Serialization 372
The Main Actor 372
Table of Contents | vii
Context Switching 374
Implicit Context Switching 374
Explicit Context Switching 375
More About Tasks 377
Task Priority 377
The Current Task 378
Sleeping 378
Yielding 379
Cancellation 380
More About Actors 386
Reentrancy 386
The Keyword nonisolated 387
The Keyword isolated 388
Global Actors 389
Sendable 390
Part II. IDE
7. Anatomy of an Xcode Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
New Project 395
The Project Window 397
The Navigator Pane 399
The Inspector Pane 404
The Editor 405
Project File and Dependents 408
Contents of the Project Folder 409
Groups 410
The Target 411
Build Phases 411
Build Settings 413
Configurations 414
Schemes and Destinations 416
From Project to Built App 418
Build Settings 420
Property List Settings 420
Nib Files 421
Resources 421
Code Files 423
Frameworks and SDKs 424
viii | Table of Contents
Swift Packages 425
The App Launch Process 429
The Entry Point 429
How an App Gets Going 431
App Without a Storyboard 433
Renaming Parts of a Project 434
8. Nib Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
The Nib Editor Interface 438
Document Outline 439
Canvas 442
Inspectors 443
Loading a Nib 444
Loading a View Controller Nib 445
Loading a Main View Nib 446
Loading a View Nib Manually 447
Connections 448
Outlets 449
The Nib Owner 450
Automatically Configured Nibs 454
Misconfigured Outlets 455
Deleting an Outlet 457
More Ways to Create Outlets 457
Outlet Collections 460
Action Connections 461
More Ways to Create Actions 463
Misconfigured Actions 464
Connections Between Nibs — Not! 465
Additional Configuration of Nib-Based Instances 466
9. Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
The Documentation Window 471
Class Documentation Pages 473
Quick Help 476
Documenting Frameworks and Packages 479
Symbol Declarations 482
Header Files 483
Sample Code 484
Internet Resources 484
Table of Contents | ix
10. Life Cycle of a Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Environmental Dependencies 487
Conditional Compilation 488
Build Action 489
Permissible Runtime Environment 490
Backward Compatibility 491
Device Type 492
Arguments and Environment Variables 494
Version Control 495
Editing and Navigating Your Code 498
Text Editing Preferences 499
Multiple Selection 500
Code Completion and Placeholders 501
Snippets 502
Refactoring and Code Actions 503
Fix-it and Live Syntax Checking 505
Navigation 506
Finding 509
Running in the Simulator 510
Debugging 512
Caveman Debugging 512
The Xcode Debugger 516
Testing 524
Unit Tests 527
Interface Tests 531
Test Plans 533
Massaging the Report 535
Clean 536
Running on a Device 537
Obtaining a Developer Program Membership 537
Signing an App 538
Automatic Signing 539
Manual Signing 541
Running the App 542
Managing Development Certificates and Devices 543
Profiling 543
Gauges 544
Memory Debugging 544
Instruments 546
Localization 548
x | Table of Contents
Creating Localized Content 548
Testing Localization 553
Distribution 554
Making an Archive 555
The Distribution Certificate 556
The Distribution Profile 557
Distribution for Testing 558
Final App Preparations 560
Screenshots and Video Previews 562
Property List Settings 563
Submission to the App Store 565
Part III. Cocoa
11. Cocoa Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Subclassing 571
Categories and Extensions 574
How Swift Uses Extensions 574
How You Use Extensions 574
How Cocoa Uses Categories 575
Protocols 576
Optional Members 577
Informal Protocols 580
Some Foundation Classes 580
NSRange 581
NSNotFound 583
NSString and Friends 584
NSDate and Friends 587
NSNumber 590
NSValue 592
NSData 593
NSMeasurement and Friends 594
Equality, Hashability, and Comparison 595
NSArray and NSMutableArray 598
NSDictionary and NSMutableDictionary 600
NSSet and Friends 601
NSIndexSet 602
NSNull 603
Immutable and Mutable 603
Table of Contents | xi
Property Lists 604
Codable 605
Accessors, Properties, and Key–Value Coding 609
Swift Accessors 610
Key–Value Coding 611
How Outlets Work 612
Cocoa Key Paths 613
Uses of Key–Value Coding 614
KeyPath Notation 615
The Secret Life of NSObject 616
12. Cocoa Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
Reasons for Events 619
Subclassing 620
Notifications 621
Receiving a Notification 623
Unregistering 625
Subscribing to a Notification 626
Posting a Notification 628
Timer 629
Delegation 631
Cocoa Delegation 632
Implementing Delegation 633
Data Sources 635
Actions 636
The Responder Chain 639
Nil-Targeted Actions 640
Key–Value Observing 642
Registration and Notification 643
Unregistering 644
Key–Value Observing Example 645
Swamped by Events 647
Delayed Performance 649
13. Memory Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
Principles of Cocoa Memory Management 653
Rules of Cocoa Memory Management 654
What ARC Is and What It Does 655
How Cocoa Objects Manage Memory 656
Autorelease Pool 657
xii | Table of Contents
Memory Management of Instance Properties 659
Retain Cycles and Weak References 660
Unusual Memory Management Situations 662
Notification Observers 663
KVO Observers 664
Timers 665
Other Unusual Situations 666
Memory Management of CFTypeRefs 666
Property Memory Management Policies 668
Debugging Memory Management Mistakes 671
14. Communication Between Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
Visibility Through an Instance Property 673
Visibility by Instantiation 674
Getting a Reference 676
Visibility by Relationship 677
Global Visibility 677
Notifications and Key–Value Observing 679
The Combine Framework 680
Alternative Architectures 687
Model–View–Controller 687
Router and Data Space 687
Model–View–Presenter 688
Protocols and Reactive Programming 689
SwiftUI 690
Result Builders and Modifiers 691
State Properties 692
Bindings 694
Passing Data Downhill 694
Passing Data Uphill 696
Custom State Objects 697
Appendix. C, Objective-C, and Swift. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739

实例下载地址

O'Reilly iOS 15 Programming Fundamentals with Swift pdf

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警