- ホーム
- > 洋書
- > 英文書
- > Computer / General
Full Description
Swift for the Really Impatient is the perfect jumpstart to the Swift language for every experienced Objective-C developer. Leading iOS and OS X developers Matt Henderson and Dave Wood help you take full advantage of Swift's powerful innovations, without wasting time on basics you already know.Through expert code examples and crystal-clear explanations, Henderson and Wood reveal how Swift features improve on Objective-C and show how to make the most of them. You'll quickly master "Swift-er" techniques for using objects, classes, optionals, generics, functions, closures, and more. Each chapter includes hands-on exercises designed to reinforce and deepen your skills.You'll learn how to re-implement common Objective-C programming solutions in Swift, improving code clarity, power, and performance on both desktop and mobile devices. And, because you probably won't (or can't) abandon Objective-C anytime soon, you'll discover how to use both languages together, smoothly integrate Swift into existing projects and workflows, and gradually move your current code base into the future. Coverage includesUsing Swift's new patterns and concise, expressive syntax to produce safer, more reliable codeLeveraging the surprising power of Swift's data structuresUtilizing Swift's type system to help prevent errors common in other languagesUsing optionals to correctly handle invalid, missing, or unknown valuesImplementing generics to reduce duplication, improve power, and simplify maintenanceInteracting with C and Objective-C APIs Abstracting functionality for reusable code while maintaining type safetyIsolating code in clean, flexible, low-overhead closuresCombining Swift with Objective-C in the same projectAvoiding gotchas when importing Objective-C classes in Swift projectsNesting types to improve code clarityCreating shared objects with singletonsManaging threading and concurrency with Swift's advanced Grand Central Dispatch (GCD) patterns
Contents
Foreword xiPreface xiiiAcknowledgments xvAbout the Authors xviChapter 1: Introducing Swift 11.1 Basic Syntax 21.1.1 Variables and Constants 21.1.2 String Interpolation 51.1.3 Control Flow 61.2 Basic Data Types 101.2.1 Int 101.2.2 Double and Float 121.2.3 Bool 131.2.4 Strings 141.2.5 Arrays 151.2.6 Dictionaries 19Exercises 20Chapter 2: Diving Deeper into Swift's Syntax 212.1 Optionals 222.2 Generics 252.3 Type Annotations and Type Inference 282.4 Functions and Closures 292.4.1 Global Functions 302.4.2 Nested Functions 302.4.3 Closure Expressions 312.5 Tuples 322.6 switch Statements and Pattern Matching 34Exercises 37Chapter 3: Objects and Classes 393.1 Enumerations 413.2 Classes 453.3 Structures 493.4 Subclassing 513.5 Overloading 523.6 Overriding 543.7 Initialization 553.8 Properties 573.8.1 Computed Properties 593.8.2 Property Observers 603.8.3 lazy Properties 623.9 Subscripting 633.10 Protocols 653.11 Extensions 673.12 Access Control 68Exercises 73Chapter 4: Optionals 754.1 Optionals and nil 764.2 Validity Checking, Optional Binding, and Forced Unwrapping 784.3 Optional Chaining 814.4 Implicitly Unwrapped Optionals 86Exercises 88Chapter 5: Generics 915.1 Why Generics? 925.2 Generic Functions 925.2.1 Type Parameters 935.2.2 Using More Than One Type Parameter 945.3 Generic Types 945.3.1 Associated Types 985.3.2 The where Clause 100Exercises 101Chapter 6: Functions and Closures 1036.1 Functions 1046.1.1 Parameters 1046.1.2 External Parameter Names 1056.1.3 Default Parameter Values 1076.1.4 Variadic and inout Parameters 1086.1.5 Return Types 1106.2 Closures 1126.2.1 Inferring Parameters and the Return Value 1136.2.2 Trailing Closures 1136.3 Functional Programming Patterns 114Exercises 117Chapter 7: Working with Objective-C 1197.1 Interacting with C and Objective-C APIs 1207.1.1 Optional Properties and Return Values 1227.1.2 AnyObject Types 1237.1.3 Subclassing, Extensions, and Protocols 1247.1.4 Automatically Converted Types 1267.1.5 Selectors and Enums 1287.1.6 Working with C Code 1297.2 Working with Swift and Objective-C in a Single Project 130Exercises 133Chapter 8: Common Patterns 1358.1 Nested Types 1368.2 Singletons 1378.3 Using Grand Central Dispatch 1398.3.1 dispatch_once 1398.3.2 dispatch_async 1398.3.3 dispatch_after 1408.3.4 dispatch_apply 1408.4 Sequences and Generators 1418.5 Operators 1458.5.1 Operator Overloading 1468.5.2 Custom Operators 147Exercises 148Index 149