Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.


Swift, beginner

  • Be the first to comment

  • Be the first to like this


  1. 1. Objective-C without C
  2. 2. Language Design Lambda Optional Type Inference Generics Extension Protocol No GC (Objective-C ARC)
  3. 3. Hello World String interpolation (word) Type Inference let word = “Swift”
  4. 4. Array & Dict Use similar syntax for Array and Dictionary The key of dictionary is non-deterministic.
  5. 5. Array & Dict Array and Dictionary are copied when assigned.
  6. 6. Function & Lambda { (params) -> return type in statement } Trailing lambda. ajax(param1, label:{lambda}) can be written as ajax(param1) {lambda}
  7. 7. Closure Closures works like a class, which has instance variables. var count { () -> () in return count++ }
  8. 8. Optional String? = Optional<String> You cannot assign nil to variables. Use Optional type if it could be nil. if let unwraps the optional. Returns true if it is not nil.
  9. 9. Class
  10. 10. Protocol Protocol is interface
  11. 11. Generics func printFullname<T: Fullname>(person: T) { func printFullname(person: Fullname) {
  12. 12. Extension You can append methods to the existing classes like Ruby Monkey patch.