Recap of WWDC19に参加してきたのでまとめます。
- Project Catalyst: UIKit on the Mac is finally here! by Tim Oliver @TimOliverAU
- 基本的にはkarnelは一緒だけどUIの部分が違った
- macはAppKit、iOSはUIKit
- AppKitの歴史、UIKitの歴史
- AppKitは1994年、UIKitは2005年
- UIKitのデザインはAppKitの経験を経て改善された
- chameleonproject.orgというのがある
- UIKitのコードをAppKitのコードに変更する
- 開発者は2人しかいなくてAppleの変更をキャッチアップはできていなかったかも
- Marzipanという噂が出た
- macとiOSを一つのOSにする
- Sneak Peekが発表された
- 2019年
- Project Catalyst
- Demo
- Passcodeのようなアプリを作った
- Deployment InfoでMacにチェックいるだけでmacアプリができた
- カスタムUI以外はダークモードにも対応された
- 一番小さく縮小してもiPhoneモードにならない
- まだただのiOSアプリ
- 全てのサイズを対応する必要がある
- AppKitのAPIに正しくアクセスできない
- fontが小さい
- iOSだと分かる
- NSWIndowを使おうとするとビルドエラーになる
- precompile binaryのリビルドが必要
- steve troughton smith highcaffeinecontent.com
- https://www.highcaffeinecontent.com/blog/20190607-Beyond-the-Checkbox-with-Catalyst-and-AppKit
- MVVM with Combine by Akifumi Fukaya @akifumifukaya
- https://speakerdeck.com/akifumifukaya/mvvm-with-combine-in-swiftui
- combineはAppleが正式にサポートしたリアクティブプログラミングフレームワーク
- iOS13,watchOS6以上
- 特徴
- Generic,Type safe, Composition first, Request driven
- Composition first
- 処理をチェインできる
- Key Concepts
- Publishers
- 時系列に伝える型を定義
- 値がどう生まれどうエラーになるか
- 値型
- subscriberが登録する
- Subscribers
- publisherから入力が受け取れる
- 参照型
- Operator
- Publisher
- publiisherをサブスクライブすることをupstream
- subscriberに値を送ることをdownstream
- How to actualize MVVM with Combine
- https://github.com/akifumi/mvvm-with-combine-in-swiftui
- TextField($username)で2way bindingができる
- BindableObjectはdidChangeの実装を要求する
- didChange.send()でViewの再計算が走る
- RunLoop.mainは動かない、schedulerが実装されていない
- Publisher.Future<String?, Never>
- APIを叩いて結果を待つとかに使える
- .eraseToAnyPublisher()で型消去してくれる
- operatoerをつなぎ合わせるとgenericが深くなっていく
- onAppear() interfaceを書いてみた
- ObjjectBinding
- 動かない
- Notification Center
- Scheduler
- @Published
- https://github.com/akifumi/mvvm-with-combine-in-uiviewcontroller
- Publishers
- SwiftUIってこんなやつ Sato Takeshi @hatakenokakashi
- Pure Swift
- 宣言的レイアウト
- Design Tool
- Preview
- iOS13 or later
- チュートリアルがあるよ
- https://developer.apple.com/tutorials/swiftui/creating-and-combining-views
- Swift5.1の機能を多用している
- handling-user-input
- Viewはプロトコル、bodyの実装が必要
- @ViewBuilderはproperty wrapper
- Embeded DSLはfunction builderとImplicit returnsで実現
- function builderのproposal
- WWDC19 Recap of ML by Akira Fukunaga @kagemiku
- Create ML
- Image Clasifier ,Sound Clasifierの2つしかまだない
- データ・セット要のディレクトリを言えるる
- データは均等にいれるのが大事
- ディレクトリ構成と学習データが対応づけられる
- Domain API
- Appleが学習済みのモデルを使える
- 前処理などが不要
- Computer VisionやNLP系があります
- Image Saliency
- 写真でいうとより注目して見つけやすいものをSaliencyが高いという
- Attention based
- 人間の目の動きのデータが学習データ
- Objectness based
- 前景と背景を区別したものが学習データ
- sentiment analytis
- positive, negative
- Model flexibility
- Support 100+ NN Layers
- Instance Segmentation
- サッカー選手と背景をオンデバイスでできるようになった
- 既にモデルが沢山ある
- Model Personalization
- デバイス上で個人に最適化ができる
- MLUpdateTask(forModelAt, trainingData, configuration, completionHandler)
- Create ML
- What's new in UICollectionView by Masaki Haga
- iOS12のUICollecitonView
- performBatchUpdateを読んでData不整合によりcrash
- 親VCのVIewサイズに合わせたCellのSize指定が案外めんどくさい
- 縦CollectionViewの中に横スクロールのCollectionViewを何個か入れたいがScroll位置の保存わりとめんどくさい
- iOS13
- Data Source
- [Old] UICollectionViewDataSource
- reloadData or performBatchUpdate
- New UICollectionViewDiffableDataSource & NSDiffableDataSourceSnapshot
- apply()
- 差分からアニメーションもさせることができる
- collectionViewの差分更新はframework側でやってくれる
- apply()
- UICollectionViewDiffableDataSource
- UIColoectionViewとCellProviderを引数に初期化する
- State(Shapshot)をapplyしてCollectionViewに反映
- public typealias CellProvider = (UICollectionView, IndexPath, ItemIdentifierType) -> UICollectionViewCell?
- 注意
- snapshotにわたすsectionの値と、itemの値はhashable
- snapshotはhashvalueによって値の同一性を認識する
- つまり、hashableのdefaultの実装だと、propertyの変更だけで違うものと認識されてしまう
- hashをオーバーライドして、hasher.combine(identifier)のような記述が必要
- SwiftUI
- DefferenceUpdateがデフォルト
- StateはHashableではなく、Identifiableに準拠する
- Diffアルゴリズムはどこからくるのか
- Swift Evo: Ordered Collection Diffingというのがある
- [Old] UICollectionViewDataSource
- Layout
- CompositionalLayoutが追加された
- initでsectionかsectionProviderを渡すことができる
- public typealias UICollectionVIewCompositinalLayoutProvider = (Int, NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection?
- NSCollectionLayoutEnvironmentは親の情報が入っている
- Nested Collection View
- 縦スクロールの中の横スクロールが簡単に掛けるようになった
- let section = NSCollectionLayoutSection(group: group)
- section.orthogonalScrollingBehavior
- 勝手にスクロールビューが入る
- 画面外から戻ってきてももとのContentOffSetが残っている
- Data Source
- iOS12のUICollecitonView