インストールすると下のようなフォルダ構成になっているのでプロジェクトを立ち上げます。
立ち上げると以下のような画面になります。
ウインドウの指示通り、Other Swift Flagsにフラグを追加します。
フラグを追加したら、Cleanとプロジェクトのビルドを行います。
その後、先程のWindowのプロジェクト名を選択すると下のような画面になります。
どのメソッドがどの程度時間がかかったかが分かるようになりました。
インストールすると下のようなフォルダ構成になっているのでプロジェクトを立ち上げます。
立ち上げると以下のような画面になります。
ウインドウの指示通り、Other Swift Flagsにフラグを追加します。
フラグを追加したら、Cleanとプロジェクトのビルドを行います。
その後、先程のWindowのプロジェクト名を選択すると下のような画面になります。
どのメソッドがどの程度時間がかかったかが分かるようになりました。
iOS10になって、以下のようにAutolayoutのconstantを変更 & layoutIfNeededでアニメーションしてくれないという問題に遭遇しました。
constraint.constant = x UIView.animate(withDuration: 0.1, animations: { self.contentView.layoutIfNeeded() })
ひとまず直接constantとxを代入する事でアニメーションしてくれるようにはなりました。
constraint.constant = x UIView.animate(withDuration: 0.1, animations: { self.contentView.frame.origin.x = x })
UISearchBarのUITextFieldを取得する方法です。
subviewから無理やり取っているので、今後取れなくなる可能性もあるので注意が必要です。
let searchBar = UISearchBar() let textField = searchBar.subviews.first?.subviews.flatMap { $0 as? UITextField }.first
Swift3.0でクラス名の取得方法が少し変わっていたのでメモ。
dynamicTypeでなくtypeという大域関数を使うようになりました。
// Swift2.0 let view = UIView() NSStringFromClass(view.dynamicType)
// Swift3.0 let view = UIView() NSStringFromClass(type(of: view))
NSStringFromClassを使わずにStringを使うことも可能です。
let view = UIView() String(reflecting: type(of: view))
最近Suicaが使えると話題のApple Payについてです。
Apple Payについて最近調べていたところ、アプリ内の課金にも使える事がわかりました。
しかしアプリ内課金はIn App purchaseが既にあるので、その辺りの使い分けをどうしたらいいかを調べてみました。
Getting Started with Apple Pay - Apple Developer
It is important to understand the difference between Apple Pay and In-App Purchase. In apps, use Apple Pay to sell physical goods such as groceries, clothing, and appliances. Also use Apple Pay for services such as club memberships, hotel reservations, and tickets for events. On the other hand, use In-App Purchase to sell virtual goods such as premium content for your app and subscriptions for digital content. Coming this fall, websites can use Apple Pay for physical goods purchases as well as virtual goods purchases that will not be consumed within an iOS app.
The Apple Pay Programming Guide provides details on how to use the PassKit framework to integrate Apple Pay. The In-App Purchase Programming Guide provides details on how to use the StoreKit framework to integrate In-App Purchases.
公式ドキュメントを読んだ所、アプリ内で食料品、衣服、家電製品などの物理的な商品を購入する際に使うようです。
アプリ内のプレミアム会員や機能開放などのデジタルコンテンツは今まで通りアプリ内課金を使えば良さそうです。
UITableViewCellで、削除ボタンを出さなくした時のスペースを消す方法です。
UITableViewでは以下のようなメソッドを実装する事で編集中に削除ボタンを出さない事ができます。
override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle { return .none }
しかし消すだけだと左側にスペースが残ってしまいます。
shouldIndentWhileEditingRowAt
を実装する事でスペースを消す事ができます。
override func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { return false }
下コマンドでDerivedDataの中身を削除する事で解決しました。
rm -rf ~/Library/Developer/Xcode/DerivedData/*