2015年5月6日 星期三

iOS 8 Programming Fundamentals with Swift

iOS 8 Programming Fundamentals with Swift
Swift, Xcode, and Cocoa Basics
Publisher: O'Reilly Media
Final Release Date: March 2015
Pages: 582
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.
  • Explore Swift’s object-oriented concepts: variables and functions, scopes and namespaces, object types and instances
  • Become familiar with built-in Swift types such as numbers, strings, ranges, tuples, Optionals, arrays, and dictionaries
  • Learn how to declare, instantiate, and customize Swift object types—enums, structs, and classes
  • Discover powerful Swift features such as protocols and generics
  • Tour the lifecycle of an Xcode project from inception to App Store
  • Create app interfaces with nibs and the nib editor, Interface Builder
  • Understand Cocoa’s event-driven model and its major design patterns and features
  • Find out how Swift communicates with Cocoa’s C and Objective-C APIs
Once you master the fundamentals, you’ll be ready to tackle the details of iOS app development with author Matt Neuburg’s companion guide, Programming iOS 8.

  1. Language

    1. Chapter 1The 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
    2. Chapter 2Functions

      1. Function Parameters and Return Value
      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
      14. Curried Functions
    3. Chapter 3Variables 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
    4. Chapter 4Object Types

      1. Object Type Declarations and Features
      2. Enums
      3. Structs
      4. Classes
      5. Polymorphism
      6. Casting
      7. Type Reference
      8. Protocols
      9. Generics
      10. Extensions
      11. Umbrella Types
      12. Collection Types
    5. Chapter 5Flow Control and More

      1. Flow Control
      2. Operators
      3. Privacy
      4. Introspection
      5. Memory Management
  2. IDE

    1. Chapter 1Anatomy of an Xcode Project

      1. New Project
      2. The Project Window
      3. The Project File and Its Dependents
      4. The Target
      5. From Project to Running App
      6. Renaming Parts of a Project
      7. Bilingual Targets
    2. Chapter 2Nib Management

      1. A Tour of the Nib Editor Interface
      2. Nib Loading
      3. Connections
      4. Additional Configuration of Nib-Based Instances
    3. Chapter 3Documentation

      1. The Documentation Window
      2. Class Documentation Pages
      3. Sample Code
      4. Quick Help
      5. Symbols
      6. Header Files
      7. Internet Resources
    4. Chapter 4Life Cycle of a Project

      1. Device Architecture and Conditional Code
      2. Version Control
      3. Editing and Navigating Your Code
      4. Running in the Simulator
      5. Debugging
      6. Unit Testing
      7. Clean
      8. Running on a Device
      9. Profiling
      10. Localization
      11. Archiving and Distribution
      12. Ad Hoc Distribution
      13. Final App Preparations
      14. Submission to the App Store
  3. Cocoa

    1. Chapter 1Cocoa Classes

      1. Subclassing
      2. Categories and Extensions
      3. Protocols
      4. Some Foundation Classes
      5. Accessors, Properties, and Key–Value Coding
      6. The Secret Life of NSObject
    2. Chapter 2Cocoa Events

      1. Reasons for Events
      2. Subclassing
      3. Notifications
      4. Delegation
      5. Data Sources
      6. Actions
      7. The Responder Chain
      8. Key–Value Observing
      9. Swamped by Events
      10. Delayed Performance
    3. Chapter 3Memory 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. Chapter 4Communication Between Objects

      1. Visibility by Instantiation
      2. Visibility by Relationship
      3. Global Visibility
      4. Notifications and KVO
      5. Model–View–Controller
    5. Appendix C, Objective-C, and Swift

      1. The C Language
      2. Objective-C

摘錄一小段:
self
An instance is an object, and an object is the recipient of messages. Thus, an instance
needs a way of sending a message to itself. This is made possible by the magic word self.
This word can be used wherever the name of an instance is expected (an instance of the
appropriate type, that is).
For example, let’s say I want to keep the thing that a Dog says when it barks — namely
"woof” — in a property. Then in my implementation of bark I need to refer to that
property. I can do it like this:
class Dog {
var name = ""
var whatADogSays = "woof"
func bark() {
println(self.whatADogSays)
}
}
Similarly, let’s say I want to write an instance method speak which is merely a synonym
for bark. My speak implementation can consist of simply calling my own bark method. I
can do it like this:
class Dog {
var name = ""
var whatADogSays = "woof"
func bark() {
println(self.whatADogSays)
}
func speak() {
self.bark()
}
}
Observe that the term self in that example appears only in instance methods. When an
instance’s code says self, it is referring to this instance. If the expression self.name
appears in a Dog instance method’s code, it means the name of this Dog instance, the one
whose code is running at that moment.
It turns out that every use of the word self I’ve just illustrated is completely optional. You
can omit it and all the same things will happen:
class Dog {
var name = ""
var whatADogSays = "woof"
func bark() {
println(whatADogSays)
}
func speak() {
bark()
}
}
The reason is that if you omit the message recipient and the message you’re sending can
be sent to self, the compiler supplies self as the message’s recipient under the hood.
However, I never do that (except by mistake). As a matter of style, I like to be explicit in
my use of self. I find code that omits self harder to read and understand. And there are
situations where you must say self, so I prefer to use it whenever I’m allowed to use it.

http://shop.oreilly.com/product/0636920034278.do

沒有留言:

張貼留言

歡迎網友的交流與分享,謝謝。