使用 Xcode predictive code completion 產生 IBOutlet / IBAction
Published in
Jun 21, 2024
使用 storyboard 設計 App 畫面時,我們常會從 storyboard 的 UI 元件拉線到 Assistant 產生 IBOutlet & IBAction 的相關程式。
最近 Xcode 16 推出聰明的 predictive code completion,我們有時也可以反過來先產生 IBOutlet / IBAction 的程式再拉線。有了 predictive code completion,產生 IBOutlet / IBAction 的速度快上許多,只要輸入簡單的注解,AI 就能產生完整的 IBOutlet / IBAction 程式。
以下我們示範幾個例子。
- 已知 outlet 的名字。
想取名 accountTextField。
用左鍵拉線,從圓圈連到 text field。
或從 text filed 用右鍵拉線連到 accountTextField。
其它例子。
想取名 isCompleteButton。
- 不知道 outlet 的名字。
- 已知 action 的名字。
- 不知道 action 的名字。