weak self
weak self
一三、波肥
70: Swift Runtime 之 Method Dispatch—Static, Table, or Message
52 minutes Posted Mar 7, 2021 at 10:00 am.
0:00
52:27
Download MP3
Show notes


波肥來介紹 Swift 的 method dispatch。



{ 完整節目筆記 https://weakself.dev/episodes/70 }


👋開場


⏪上集節目回顧

聽眾 dan12411 貢獻他的 Xcode 技巧。


📰一週開發者新聞


⭐️Swift Runtime 1—Method Dispatch in Swift/ObjC: Static, Table, Message Dispatch
  • struct 的 func 一定是 static dispatch。因為 optimization 設定的不同,有可能會是 inline
  • class 的 func 通常是 table dispatch。如果加了 final 或是在 extension 定義新 func 就會是 static。
  • Swift 裡的NSObject subclass,一般 func 也是 table dispatch,即使加了 @objc 也一樣。若是 @objc dynamic就會是 message dispatch。如果加了 final 就會是 static
  • 想要自行研究的話,可以用以下方法(程式碼請見完整節目筆記
  • 用 swiftc -emit-silgen Foo.swift -Onone 即可得到 SIL


💸勸敗話題


👋收尾


更多 weak self

--
Hosting provided by SoundOn