以前下記のような記事を書いた。
永遠ログ:[Swift2]NSCalendarUnitの合成
Swiftは頻繁に文法が変わり、APIの変更もあるのだがこの回りはどんどん変わっている。Swift3ではほとんど書いていないので分からないのだが、Swift4で同じ事をしようとしたらまた変わっていた。Swift3でも同じようだ。
Dateから年・月・日などの数字だけを抜き出すときのこと。Objective-C時代は NSCalendarUnit だったが、それがSwift2では NSDateComonents を使うようになっていた。Swift4は Calendar.Compontent を使う。
例えば、ある日付データから何日かを取得するには以下を使う。
続きを読む
2018年07月29日
2018年03月05日
「Unityの寺子屋 定番スマホゲーム開発入門」
そろそろUnityも使ってみようかなあと思いわかりやすそうな本を読んでみた。
かつて話題になったMagic Readerの共同開発者の一人が監修・著者の本。ただしMagic ReaderはUnityじゃないはず。
図版が多く、ステップバイステップでほとんど省略がなく「〜と同様に」という手順も簡略化してではあるが決して省くことなく記述してくれているのでしっかり手順を追って作成していけば初心者でも実際に動くアプリを作成することができた。
続きを読む
2017年12月07日
WWDC17 | Session 219 | Modern User Interaction on iOS
36:18
https://developer.apple.com/videos/play/wwdc2017/219/
iOSでのユーザー操作の現代的実装にはUIGestureRecognizerが多く使われている。UIGestureRecognizerの基本の復習とiOS11でのアップデート状況。
□基本
UITouch
UIGestureRecognizer
UITouchにより起動されたUIGestureRecognizerの内部状態がどのように変化して、ハンドラーにそれがどう伝達されるかをステップバイステップで図を使って解説。
began
ended
cancelled
moved
failed
等の内部イベント、
possible
failed
の内部状態について説明
続きを読む
https://developer.apple.com/videos/play/wwdc2017/219/
iOSでのユーザー操作の現代的実装にはUIGestureRecognizerが多く使われている。UIGestureRecognizerの基本の復習とiOS11でのアップデート状況。
□基本
UITouch
UIGestureRecognizer
UITouchにより起動されたUIGestureRecognizerの内部状態がどのように変化して、ハンドラーにそれがどう伝達されるかをステップバイステップで図を使って解説。
began
ended
cancelled
moved
failed
等の内部イベント、
possible
failed
の内部状態について説明
続きを読む
2017年12月03日
WWDC17 | Session 204 | Updating Your App for iOS 11
30:56
https://developer.apple.com/videos/play/wwdc2017/204/
iOS11で導入された新しい機能について述べる。
UIKitのbar(UIToolbar, UINavigationbar, UISearchbar)に関する機能。Scroll View, Table Viewなどで導入されたマージンと余白(インセット)の新機能。
■各種バー
□Tab Bar
横向き(Landscape)で小さなアイコンを表示。このアイコンが見にくい場合には、長押しでHUDでアイコン・テキストを表示する。→アクセシビリティのセッションで詳述
UIBarItem.landscapeImagePhone
UIBarItem.largeContentSizeImage
□Navigation Bar
・大きなタイトル文字表示
nagigationBarprefersLargeTitles = true
nagigationItem.largeTitleDisplayMode
Automatic, Never, Always
・検索窓用のコントローラー
nagigationItem.searchController
navigationItem.hidesSearchBarWhrnScrolling
・拡張レイアウト項目
UIToolbar and UINavigationBarで表示エリアを指定できる。
Demo 10:13〜
■Margins and Insets
layoutMargins .left .right
(新)directionallayoutMargins .trailing .leading
書籍アプリなどで左ページ、右ページでマージンが左右逆になるのを自動調整する時に有用。
systemMinimuLayoutMargins
viewRespectsSytemMinimumLayoutMargins = true
(新)SafeArea の導入で内側のビューのテキスト等の表示領域を限定できる。
□Scroll View
adjustedContentInset.top
□Table Views
Self-sizeing
Safe Area
(新)Swipe Actions
leading Swipe, trailing Swipe
Demo 24:03〜
https://developer.apple.com/videos/play/wwdc2017/204/
iOS11で導入された新しい機能について述べる。
UIKitのbar(UIToolbar, UINavigationbar, UISearchbar)に関する機能。Scroll View, Table Viewなどで導入されたマージンと余白(インセット)の新機能。
■各種バー
□Tab Bar
横向き(Landscape)で小さなアイコンを表示。このアイコンが見にくい場合には、長押しでHUDでアイコン・テキストを表示する。→アクセシビリティのセッションで詳述
UIBarItem.landscapeImagePhone
UIBarItem.largeContentSizeImage
□Navigation Bar
・大きなタイトル文字表示
nagigationBarprefersLargeTitles = true
nagigationItem.largeTitleDisplayMode
Automatic, Never, Always
・検索窓用のコントローラー
nagigationItem.searchController
navigationItem.hidesSearchBarWhrnScrolling
・拡張レイアウト項目
UIToolbar and UINavigationBarで表示エリアを指定できる。
Demo 10:13〜
■Margins and Insets
layoutMargins .left .right
(新)directionallayoutMargins .trailing .leading
書籍アプリなどで左ページ、右ページでマージンが左右逆になるのを自動調整する時に有用。
systemMinimuLayoutMargins
viewRespectsSytemMinimumLayoutMargins = true
(新)SafeArea の導入で内側のビューのテキスト等の表示領域を限定できる。
□Scroll View
adjustedContentInset.top
□Table Views
Self-sizeing
Safe Area
(新)Swipe Actions
leading Swipe, trailing Swipe
Demo 24:03〜
2017年12月01日
WWDC17 | Session 402 | What's New in Swift
59:29
https://developer.apple.com/videos/play/wwdc2017/402/
Swift4の更新情報
□アクセス制御
private
extension からのアクセス不可なので fileprivate を使う。(Swift3)。
→ SE-0169: Improve Interaction Between Private Declarations and Extensions
Swift4 は、privateのままで使える。
SE-0156: Class and Subtype Existentials
□Cocoa Idioms
下記など。紹介は省略し、別セッション(202 What's New in Foundation)で解説。
KeyPaths, Archival & Serialization, Encoder
SE-0161 Smart KeyPaths: Better Key-Value Coding for Swift SE-0166 Swift Archival & Serialization
SE-0167 Swift Encoders
□ソース互換性
Swift 3.2のソースをSwift4 でほとんどそのままコンパイル可能
移行ツールあり
ひとつのプロジェクトでターゲットごとに3.2/4 の切り替え可能
Package Support Swift Versionを記述
□ビルドの高速化、バイナリの効率化
New Build Systemを選択可能
Precompiled Header
Shared Build
Indexing While Building
COW Existential Buffers = COW(copy-on-write)
Faster Generic Code
Smaller Binaries
Unused Conformance Removal
@objc inference
□String
Unicode合成文字の比較
charactersカウンティング
charactesのコレクションをString自身がもつ
Owner Reference Count (Substring
String(_:Substring) copies the buffer
複数行文字列 = """
□New Generics
associatedtype
subscripts partioal range
□Standard Library の新機能
多数。詳細説明なし。
□Exclusive Access to memory
Ownership
https://developer.apple.com/videos/play/wwdc2017/402/
Swift4の更新情報
□アクセス制御
private
extension からのアクセス不可なので fileprivate を使う。(Swift3)。
→ SE-0169: Improve Interaction Between Private Declarations and Extensions
Swift4 は、privateのままで使える。
SE-0156: Class and Subtype Existentials
□Cocoa Idioms
下記など。紹介は省略し、別セッション(202 What's New in Foundation)で解説。
KeyPaths, Archival & Serialization, Encoder
SE-0161 Smart KeyPaths: Better Key-Value Coding for Swift SE-0166 Swift Archival & Serialization
SE-0167 Swift Encoders
□ソース互換性
Swift 3.2のソースをSwift4 でほとんどそのままコンパイル可能
移行ツールあり
ひとつのプロジェクトでターゲットごとに3.2/4 の切り替え可能
Package Support Swift Versionを記述
□ビルドの高速化、バイナリの効率化
New Build Systemを選択可能
Precompiled Header
Shared Build
Indexing While Building
COW Existential Buffers = COW(copy-on-write)
Faster Generic Code
Smaller Binaries
Unused Conformance Removal
@objc inference
□String
Unicode合成文字の比較
charactersカウンティング
charactesのコレクションをString自身がもつ
Owner Reference Count (Substring
String(_:Substring) copies the buffer
複数行文字列 = """
□New Generics
associatedtype
subscripts partioal range
□Standard Library の新機能
多数。詳細説明なし。
□Exclusive Access to memory
Ownership

