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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
iganin
November 29, 2019
Programming
0
780
Swift 5.1の変更点
2019/11/29 yumemi.swiftでの発表内容です。
iganin
November 29, 2019
Tweet
Share
More Decks by iganin
See All by iganin
Amazon Bedrock AgentCore 認証・認可入門
hironobuiga
1
160
AgentCoreで実現するマルチテナントAIエージェント
hironobuiga
1
13
FlutterでGraphQL のuseQueryを使う
hironobuiga
0
8
FlutterでGraphQLを扱う
hironobuiga
0
5
FlutterでScrollViewとExpandedを併用し てSignIn / SignUp画面 など レイアウトを作成する
hironobuiga
0
5
Data Race and Actor
hironobuiga
0
60
20210625-meet-async-await@swift愛好会
hironobuiga
1
1.6k
IBDesignable を活用する
hironobuiga
0
4
Codableあるある
hironobuiga
0
5
Other Decks in Programming
See All in Programming
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.3k
CSC307 Lecture 01
javiergs
PRO
0
680
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
520
CSC307 Lecture 03
javiergs
PRO
1
480
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
270
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
400
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
410
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
190
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
170
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2.3k
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
420
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
0
980
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
47
Faster Mobile Websites
deanohume
310
31k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
200
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.4k
Code Reviewing Like a Champion
maltzj
527
40k
For a Future-Friendly Web
brad_frost
181
10k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Writing Fast Ruby
sferik
630
62k
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!