Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swift 5.1の変更点
Search
iganin
November 29, 2019
Programming
0
730
Swift 5.1の変更点
2019/11/29 yumemi.swiftでの発表内容です。
iganin
November 29, 2019
Tweet
Share
More Decks by iganin
See All by iganin
Data Race and Actor
hironobuiga
0
52
20210625-meet-async-await@swift愛好会
hironobuiga
1
1.6k
Other Decks in Programming
See All in Programming
Kiroで始めるAI-DLC
kaonash
2
150
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
240
Namespace and Its Future
tagomoris
6
650
TanStack DB ~状態管理の新しい考え方~
bmthd
2
360
物語を動かす行動"量" #エンジニアニメ
konifar
14
5.6k
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
3
1.7k
あのころの iPod を どうにか再生させたい
orumin
2
2.5k
Improving my own Ruby thereafter
sisshiki1969
1
130
AI時代に学習する意味はあるのか?
tomoyakamaji
0
100
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
750
ワープロって実は計算機で
pepepper
2
1.4k
Google I/O recap web編 大分Web祭り2025
kponda
0
2.9k
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
Designing Experiences People Love
moore
142
24k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Gamification - CAS2011
davidbonilla
81
5.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
20k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Optimizing for Happiness
mojombo
379
70k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.5k
GraphQLとの向き合い方2022年版
quramy
49
14k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.5k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
Swift 5.1 の変更点 2019/11/29 yumemi.swift Hironobu Iga
自己紹介 Hironobu Iga( Iganin ) Freelance Mobile App Engineer( iOS
, Android) • Twitter: @iganin_dev • Hatena: Iganin • Qiita: @iganin
話すこと • ざっくりとしたSwift 5.1 の変更点確認 • Pickup ◦ SE-0242 Synthesize
default values for the memberwise initializer ◦ SE-0068 Expanding Swift Self to class members and value types • まとめ
Swift5.1の変更点 (ざっくり)
Swift 5.1で入った変更点 Swift UIの導入もあり、非常に多くの変更が入っています。 簡単にキーワードを上げていきます。
Swift 5.1で入った変更点 Module Stability swiftmodule の ライブラリInterface定義の安定化により、ライブラリのコンパイル時に 使用したSwiftバージョンとアプリのSwiftバージョンが異なっても大丈夫に Additional Language
and Compiler Update SwiftUIの導入と共に多くの変更が入っています • Property Wrapper • Opaque Result Types • single expression の場合はreturn 不要 ( var sample: String { “sample” } ) • Key Path Member Lookup • etc
Swift 5.1で入った変更点 Standard Library Updates Collectionsの扱い, Arrayの初期化, StringにいくつかのAPIが追加 ,Identifiableプロトコ ルの導入など
Language Server Protocol LSPをサポートしているエディターであれば、Swiftのコード補完やシンタックスハイライ ト、ジャンプ機能などが使えるように
PickUpして話すこと Swift UI の導入もあり多くの変更点があります それぞれの内容は深く、他の勉強会でも語られているため 本日の発表ではあまり他の勉強会でみなかった2つをPickupします • SE-0242 Synthesize default
values for the memberwise initializer • SE-0068 Expanding Swift Self to class members and value types
SE-0242 Synthesize default values for the memberwise initializer
Synthesize default values for the memberwise initializer ざっくり説明 Structの自動生成される初期化メソッドがより便利になった
Synthesize default values for the memberwise initializer 従来は、 `var id:
Int = 0` と定義していてもデフォルト値を考慮した初期化メソッドは生成 されていませんでした
Synthesize default values for the memberwise initializer User(name: “Tanaka”) のように初期化するためには、
明示的に定義する必要がありま した
Synthesize default values for the memberwise initializer var id: Int
= 0 を考慮した初期化メソッド init(id: Int = 0, name: String) のようにデフォルト引数を考慮した初期化メソッドが自動生 成されるようになり、明示的にメソッドを作成する必要がなくなりました OK!
SE-0068 Expanding Swift Self to class members and value types
Expanding Swift Self to class members and value types ざっくり説明
class内からstatic変数やメソッドにアクセスしやすくなりました
Expanding Swift Self to class members and value types staticなhogeという変数とfugaというメソッドを定義します。
struct内からアクセスする際に従来は ${Struct名}.変数 や type(of: self).変数とする必 要がありました。
Expanding Swift Self to class members and value types Swift
5.1 以降では、 class, struct, enum内から staticな変数やメソッドにアクセスする際 に、 Self を利用できるようになりました OK!
Expanding Swift Self to class members and value types インスタンス変数・メソッドへのアクセス
• self.変数 • self.メソッド staticへ変数・メソッドへのアクセス • Self.変数 • Self.メソッド 上記のように綺麗な対比関係ができました
まとめ • Swift UI の導入もあり、多くの変更点 • 2つの変更をPickup ◦ structの自動生成初期化メソッドが便利に ◦
staticな変数・メソッドにSelfでアクセス可能に
補足 Swift.orgの1次情報にあたるのはとてもオススメです • https://swift.org/blog/ Swift 5.1の新機能が解説されているPlaygroundが GitHubにありオススメです • twostraws/whats-new-in-swift-5-1 ◦
GitHub: https://github.com/twostraws/whats-new-in-swift-5-1 ◦ 関連記事: https://github.com/twostraws/whats-new-in-swift-5-1
Thank you!