Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS_meetup.pdf

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Ambas Ambas
October 29, 2018
120

 iOS_meetup.pdf

Avatar for Ambas

Ambas

October 29, 2018

Transcript

  1. Agenda 1. Function in Fruit of Knowledge 2. Price of

    Changing 3. Function Biology 4. The Coming of the Feature
  2. Function “In programming, a named section of a program that

    performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value. Most programming languages come with a prewritten set of functions that are kept in a library. You can also write your own functions to perform specialized tasks.”
  3. Function in Fruit of Knowledge • Objective-C was originally developed

    in the early 1980s • used by NeXT for its NeXTSTEP operating system (1988) • Swift was introduced at WWDC’ 14
  4. Static vs Dynamic Dispatch • Dynamic Dispatch • Message passing

    • Dynamic binding • Static Dispatch • Know location of method at compile time • Static type
  5. Swift Feature • Optional • Tuples and multiple return values

    • Struct • Powerful error handling • Generic • Functional programming patterns, e.g., map and filter • Etc.
  6. Function Biology 1. Functions can be assigned to variables and

    passed in and out of other functions as arguments. 2. Functions can capture variables that exist outside of their local scope. 3. Functions can be declared using the { } syntax for closure expressions.
  7. 1. Functions can be assigned to variables and passed in

    and out of other functions as arguments. • Function is first class objects • Assign function as a variable
  8. 1. Functions can be assigned to variables and passed in

    and out of other functions as arguments. • Function can take a function as an argument
  9. 1. Functions can be assigned to variables and passed in

    and out of other functions as arguments. • Function can also return a functions
  10. 2. Functions can capture variables that exist outside of their

    local scope. • When function reference to variable outside function’s scope, those variable are capture
  11. 3. Functions can be declared using the { } syntax

    for closure expressions. • In swift we can define function in two ways
  12. 3. Functions can be declared using the { } syntax

    for closure expressions. • Closure expression
  13. 3. Functions can be declared using the { } syntax

    for closure expressions. • Closure expression
  14. Conclusions • We are in the long way of history

    but swift is so young • We lose something but… • Writing code for understanding at a glance • Improve, improve and improve
  15. References • Advance Swift Book https://www.objc.io/books/advanced-swift/ • Function Definition https://en.wikipedia.org/wiki/Closure_(computer_programming)

    • Memory management https://medium.com/@itchyankles/memory-management-in-rust-and-swift-8ecda3cdf5b7 • Swift performance measurement https://yalantis.com/blog/is-swift-faster-than-objective-c/ • Dynamic binding https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia- CocoaCore/DynamicBinding.html#//apple_ref/doc/uid/TP40008195-CH15-SW1 • KVO https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueObserving/ KeyValueObserving.html • Using Collection Operators https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ KeyValueCoding/CollectionOperators.html#//apple_ref/doc/uid/20002176-BAJEAIEE • Compile Time vs. Run Time Type Checking in Swift http://blog.benjamin-encz.de/post/compile-time-vs-runtime- type-checking-swift/ • 5 things you can do with Objective-C but can’t do with pure Swift https://medium.com/@markohlebar/5-things-you- can-do-in-objective-c-but-cant-do-in-pure-swift-31bb66b4aab8 • Closures https://docs.swift.org/swift-book/LanguageGuide/Closures.html