7. もくじ
1. Swiftトピックス
o Swiftってどんな言語?
o この文法だけは今日覚えときましょう
2. アプリってどう動いてるの?
o アプリが動くのに必要な登場人物を知る
3. で、どう作るの?
o Xcode(コーディング→ コンパイル→ ビルド)
o 常連さんを知る(一見さんを見分ける)
4. やりたいこと別、使うFramework
5. UIを扱うには?
7
9. Swiftトピックス
• 関数型言語系機能
o 定数宣言(Scala のval)
o Optional型(Scala)
o タプル(Scala)
o クロージャ(JavaScript)
o 高階関数(JavaScript)
o 関数のカリー化(Scala)
• オブジェクト指向系機能
o ジェネリクス(JavaのArray<T>)
• その他便利機能
o nil結合演算子(JavaScriptの|| )
o lazy修飾子(Scala)
o カスタム演算子
9
使わなくても
アプリは作れます
Java7やPHPよりは
自由度が高い
(=覚えることが多い)
くらいのイメージでOK
10. Swiftトピックス
• 関数型言語系機能
o 定数宣言(Scala のval)
o Optional型(Scala)
o タプル(Scala)
o クロージャ(JavaScript)
o 高階関数(JavaScript)
o 関数のカリー化(Scala)
• オブジェクト指向系機能
o ジェネリクス(JavaのArray<T>)
• その他便利機能
o nil結合演算子(JavaScriptの|| )
o lazy修飾子(Scala)
o カスタム演算子
10
var animator: UIDynamicAnimator?
attachmentBehavior = UIAttachmentBehavior(…)
attachmentBehavior?.frequency = 0
animator!.addBehavior(attachmentBehavior)
!とか?とか検索できない!!
34. アプリ開発でやること
• 実装
o StoryboardでUI部品の配置
o ソースファイルに動作をプログラミング
• 各種画像の設定
o アイコン
o 起動時画像
• ユニバーサル対応
o どの大きさの端末でも動くように対応(Auto Layout)
• 多言語対応
o ベースは英語+ 日本語が一般的
34
35. アプリ開発でやること
• 実装
o StoryboardでUI部品の配置
o ソースファイルに動作をプログラミング
• 各種画像の設定
o アイコン
o 起動時画像
• ユニバーサル対応
o どの大きさの端末でも動くように対応(Auto Layout)
• 多言語対応
o ベースは英語+ 日本語が一般的
35
完璧を求めなくて
いいんです
36. 実演
• 画面のデザイン
o Imageファイルを設置
• デモプロジェクト
o https://github.com/uskithub/SwiftUI
36
46. import UIKit
classViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
UIKitという名前の道具箱を
使うよ、という指示
46
47. import UIKit
classViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
道具箱の中のViewController の
型紙を使って、新しい
ViewController を作っている
47
48. import UIKit
classViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
func ◯◯ は◯◯メソッドと
呼び、処理のひと塊に名前
を付けたもの
48
49. import UIKit
classViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
viewDidLoadは、Viewが
ロードされた後に呼ばれる
処理を指示できるメソッド
49
50. import UIKit
classViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
didReceiveMemoryWarningは
「メモリが足んないよ」とOS
から警告が来た時の処理を指
示するためのメソッド
50
51. import UIKit
classViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
super.メソッド名は、型紙
で決まられた元々の処理を
実行する、という指示
51