LoginSignup
0
1

More than 3 years have passed since last update.

[Swift] Connectionの概要・使い方まとめ

Posted at

自己紹介的な

Swift歴2日目の超初級者。
本記事では学習したことをアウトプットして、自分の中で定着させることを目的としています。
初学者のスタートダッシュの手助けになれば幸いです。

Connectionについて

UI部品とコードを関連付ける際に、コード上でUI部品にどのような役割を持たせるか指定することができる。
具体的には、ConnectionにOutletかActionを設定することで指定できる。

OutletとActionって何ぞや?

OutletとActionはどのように使い分ける?
色々調べたことをまとめると、
・Outlet → そのUI部品をどこかで参照したいとき
・Action → そのUI部品の動作内容を決めたいとき

例えば、buttonを押したらlabelに"Hello World"が出力される場合を考える。
buttonはlabelを参照して"Hello World"を代入する、つまりUI部品の動作内容を決めているのでAction。
labelは、buttonから参照されているのでOutlet。

おわりに

もし間違っていたらご指摘頂けると助かります。。。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1