iOS 8 Programming Fundamentals with Swift

Book description

Move into iOS development by getting a firm grasp of its fundamentals, including the Xcode IDE, the Cocoa Touch framework, and Swift—Apple’s new programming language. With this thoroughly updated guide, you’ll learn Swift’s object-oriented concepts, understand how to use Apple’s development tools, and discover how Cocoa provides the underlying functionality iOS apps need to have.

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. The Scope of This Book
    2. Versions
    3. Acknowledgments
    4. From the Programming iOS 4 Preface
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
  2. I. Language
    1. 1. The Architecture of Swift
      1. Ground of Being
      2. Everything Is an Object?
      3. Three Flavors of Object Type
      4. Variables
      5. Functions
      6. The Structure of a Swift File
      7. Scope and Lifetime
      8. Object Members
      9. Namespaces
      10. Modules
      11. Instances
      12. Why Instances?
      13. self
      14. Privacy
      15. Design
        1. Object Types and APIs
        2. Instance Creation, Scope, and Lifetime
        3. Summary and Conclusion
    2. 2. Functions
      1. Function Parameters and Return Value
        1. Void Return Type and Parameters
        2. Function Signature
      2. External Parameter Names
      3. Overloading
      4. Default Parameter Values
      5. Variadic Parameters
      6. Ignored Parameters
      7. Modifiable Parameters
      8. Function In Function
      9. Recursion
      10. Function As Value
      11. Anonymous Functions
      12. Define-and-Call
      13. Closures
        1. How Closures Improve Code
        2. Function Returning Function
        3. Closure Setting a Captured Variable
        4. Closure Preserving Its Captured Environment
      14. Curried Functions
    3. 3. Variables and Simple Types
      1. Variable Scope and Lifetime
      2. Variable Declaration
      3. Computed Initializer
      4. Computed Variables
      5. Setter Observers
      6. Lazy Initialization
      7. Built-In Simple Types
        1. Bool
        2. Numbers
          1. Int
          2. Double
          3. Coercion
          4. Other numeric types
          5. Arithmetic operations
          6. Comparison
        3. String
        4. Character
        5. Range
        6. Tuple
        7. Optional
          1. Unwrapping an Optional
          2. Implicitly unwrapped Optional
          3. The magic word nil
          4. Optional chains
          5. Comparison with Optional
          6. Why Optionals?
    4. 4. Object Types
      1. Object Type Declarations and Features
        1. Initializers
          1. Optional properties
          2. Referring to self
          3. Delegating initializers
          4. Failable initializers
        2. Properties
        3. Methods
        4. Subscripts
        5. Namespaced Object Types
        6. Instance References
      2. Enums
        1. Case With Fixed Value
        2. Case With Typed Value
        3. Enum Initializers
        4. Enum Properties
        5. Enum Methods
        6. Why Enums?
      3. Structs
        1. Struct Initializers, Properties, and Methods
        2. Struct As Namespace
      4. Classes
        1. Value Types and Reference Types
        2. Subclass and Superclass
        3. Class Initializers
          1. Surprises from Cocoa
          2. Required initializers
        4. Class Deinitializer
        5. Class Properties and Methods
      5. Polymorphism
      6. Casting
      7. Type Reference
      8. Protocols
        1. Why Protocols?
        2. Protocol Type Testing and Casting
        3. Declaring a Protocol
        4. Optional Protocol Members
        5. Class Protocol
        6. Implicitly Required Initializers
        7. Literal Convertibles
      9. Generics
        1. Generic Declarations
        2. Type Constraints
        3. Explicit Specialization
        4. Where Clauses
      10. Extensions
      11. Umbrella Types
        1. AnyObject
          1. Suppressing type checking
          2. Object identity
        2. AnyClass
        3. Any
      12. Collection Types
        1. Array
          1. Array casting and type testing
          2. Array comparison
          3. Arrays are value types
          4. Array subscripting
          5. Nested arrays
          6. Basic array properties and methods
          7. Array enumeration and transformation
          8. Swift Array and Objective-C NSArray
        2. Dictionary
          1. Basic dictionary properties and enumeration
          2. Swift Dictionary and Objective-C NSDictionary
        3. Set
    5. 5. Flow Control and More
      1. Flow Control
        1. Branching
          1. If construct
          2. Conditional binding
          3. Switch statement
          4. Conditional evaluation
        2. Loops
          1. While loops
          2. For loops
        3. Jumping
        4. Aborting
      2. Operators
      3. Privacy
        1. Private Declaration
        2. Public Declaration
        3. Privacy Rules
      4. Introspection
      5. Memory Management
        1. Weak References
        2. Unowned References
        3. Weak and Unowned References in Anonymous Functions
        4. Memory Management of Protocol-Typed References
  3. II. IDE
    1. 6. Anatomy of an Xcode Project
      1. New Project
      2. The Project Window
        1. The Navigator Pane
        2. The Utilities Pane
        3. The Editor
      3. The Project File and Its Dependents
      4. The Target
        1. Build Phases
        2. Build Settings
        3. Configurations
        4. Schemes and Destinations
      5. From Project to Running App
        1. Build Settings
        2. Property List Settings
        3. Nib Files
        4. Additional Resources
        5. Code Files and the App Launch Process
          1. The entry point
          2. UIApplicationMain
          3. App without a storyboard
        6. Frameworks and SDKs
      6. Renaming Parts of a Project
      7. Bilingual Targets
    2. 7. Nib Management
      1. A Tour of the Nib Editor Interface
        1. The Document Outline
        2. Canvas
        3. Inspectors and Libraries
      2. Nib Loading
        1. When Nibs Are Loaded
        2. Manual Nib Loading
      3. Connections
        1. Outlets
        2. The Nib Owner
        3. Automatically Configured Nibs
        4. Misconfigured Outlets
        5. Deleting an Outlet
        6. More Ways to Create Outlets
        7. Outlet Collections
        8. Action Connections
        9. More Ways to Create Actions
        10. Misconfigured Actions
        11. Connections Between Nibs — Not!
      4. Additional Configuration of Nib-Based Instances
    3. 8. Documentation
      1. The Documentation Window
      2. Class Documentation Pages
      3. Sample Code
      4. Quick Help
      5. Symbols
      6. Header Files
      7. Internet Resources
    4. 9. Life Cycle of a Project
      1. Device Architecture and Conditional Code
        1. Backward Compatibility
        2. Device Type
      2. Version Control
      3. Editing and Navigating Your Code
        1. Autocompletion
        2. Snippets
        3. Fix-it and Live Syntax Checking
        4. Navigation
        5. Finding
      4. Running in the Simulator
      5. Debugging
        1. Caveman Debugging
        2. The Xcode Debugger
          1. Breakpoints
          2. Paused at a breakpoint
      6. Unit Testing
      7. Clean
      8. Running on a Device
        1. Obtaining a Certificate
        2. Obtaining a Development Provisioning Profile
        3. Running the App
        4. Profile and Device Management
      9. Profiling
        1. Gauges
        2. Instruments
      10. Localization
        1. Localizing the Info.plist
        2. Localizing a Nib File
        3. Localizing Code Strings
        4. Localizing With XML Files
      11. Archiving and Distribution
      12. Ad Hoc Distribution
      13. Final App Preparations
        1. Icons in the App
        2. Other Icons
        3. Launch Images
        4. Screenshots and Video Previews
        5. Property List Settings
      14. Submission to the App Store
  4. III. Cocoa
    1. 10. Cocoa Classes
      1. Subclassing
      2. Categories and Extensions
        1. How Swift Uses Extensions
        2. How You Use Extensions
        3. How Cocoa Uses Categories
      3. Protocols
        1. Informal Protocols
        2. Optional Methods
      4. Some Foundation Classes
        1. Useful Structs and Constants
        2. NSString and Friends
        3. NSDate and Friends
        4. NSNumber
        5. NSValue
        6. NSData
        7. Equality and Comparison
        8. NSIndexSet
        9. NSArray and NSMutableArray
        10. NSDictionary and NSMutableDictionary
        11. NSSet and Friends
        12. NSNull
        13. Immutable and Mutable
        14. Property Lists
      5. Accessors, Properties, and Key–Value Coding
        1. Swift Accessors
        2. Key–Value Coding
        3. Uses of Key–Value Coding
        4. KVC and Outlets
        5. Key Paths
        6. Array Accessors
      6. The Secret Life of NSObject
    2. 11. Cocoa Events
      1. Reasons for Events
      2. Subclassing
      3. Notifications
        1. Receiving a Notification
        2. Unregistering
        3. Posting a Notification
        4. NSTimer
      4. Delegation
        1. Cocoa Delegation
        2. Implementing Delegation
      5. Data Sources
      6. Actions
      7. The Responder Chain
        1. Deferring Responsibility
        2. Nil-Targeted Actions
      8. Key–Value Observing
      9. Swamped by Events
      10. Delayed Performance
    3. 12. Memory Management
      1. Principles of Cocoa Memory Management
      2. Rules of Cocoa Memory Management
      3. What ARC Is and What It Does
      4. How Cocoa Objects Manage Memory
      5. Autorelease Pool
      6. Memory Management of Instance Properties
      7. Retain Cycles and Weak References
      8. Unusual Memory Management Situations
      9. Nib Loading and Memory Management
      10. Memory Management of CFTypeRefs
      11. Property Memory Management Policies
      12. Debugging Memory Management Mistakes
    4. 13. Communication Between Objects
      1. Visibility by Instantiation
      2. Visibility by Relationship
      3. Global Visibility
      4. Notifications and KVO
      5. Model–View–Controller
    5. A. C, Objective-C, and Swift
      1. The C Language
        1. C Data Types
        2. C Enums
        3. C Structs
        4. C Pointers
        5. C Arrays
        6. C Functions
      2. Objective-C
        1. Objective-C Objects and C Pointers
        2. Objective-C Objects and Swift Objects
        3. Objective-C Methods
        4. Objective-C Initializers and Factories
        5. Selectors
        6. CFTypeRefs
        7. Blocks
  5. Index
  6. Colophon
  7. Copyright

Product information

  • Title: iOS 8 Programming Fundamentals with Swift
  • Author(s):
  • Release date: March 2015
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491908907