Apple Watch のセルラーモデルで夢広がるかと思って調べてたら問題点が結構あった
やりたい感じ
セルラーモデルの単体動作
- いずれも、事前にiPhoneとのペアリングが完了していることが条件
Apple Watchだけで使うことができる通信が必要なアプリ
電話 メッセージの送受信 Apple Musicのストリーミング再生 マップ Siri 通知 Apple Payの利用 アクティビティ/ワークアウト タイマー/ストップウォッチ/アラーム 天気/株/リマインダー/カレンダー
すげぇ。 apple
iPhoneがないと「初期セットアップ」が行えない。
- 相変わらず利用するためには事前にiPhoneとのペアリングが必須。
- Apple Watch単体のLTE通信で全てのアプリを動作させることはできない。
- iPhoneを使って設定をすれば、実際にiPhoneの電源を切って電話を掛けてみましたが、普通に電話を掛けることができる。
https://www.sin-space.com/entry/apple-watch-3-review-0926 https://www.earlyteches.com/2017/09/apple-watch-no-iphone-day/
iPhone と Apple Watch で同じ通信事業者を利用する必要がある。
https://support.apple.com/ja-jp/HT207578
セルラーモデルの通信
キャリアのみと契約したiPhoneが必須。 docomo : 500円/月, au, softbank : 350円/月
https://support.apple.com/ja-jp/HT207578
一つのiPhoneで複数接続
- Apple Watch Series 3 (GPS + Cellular) をペアリングできますが、通信事業者によっては、有効なモバイルデータ通信プランを同時に複数は扱えない場合があります。
- 一度に 1 つの Apple Watch だけがアクティブになります。切り替えるには、使用中の Apple Watch を外して別の Apple Watch を身に着け、手首を上げるか腕を動かします。watchOS は、一度に 2 つの Apple Watch の装着には対応していません。複数のユーザの間で同時に Apple Watch を共有することもできません。
apple watch 1台につきiPhone1台必要。
https://support.apple.com/ja-jp/HT205792
iPadとの連携について
- 実際にiOS8.3のiPadAirで確認してみたところ連携用のApple watch Appが見つかりませんでした。 http://xn--cckaf1mbm6kze4b.com/apple-watch-ipad-2756
- Apple WatchはiPhone専用のスマートウォッチだ。Androidスマートフォンと連携させられないし、iPod touch、iPadと接続することもできない。
今のところ、Apple watchはiPhone専用の端末
公式でもセットアップ端末はiPhoneのみ。
- iPad Proとの連携という観点では、iPad Pro側でWatch.appが利用できないため、Apple Watchの設定を変更したりアプリをインストールしたりということはできない。
http://xn--cckaf1mbm6kze4b.com/apple-watch-ipad-2756 https://support.apple.com/ja-jp/HT204505 https://www.episode02.com/entry/2017/09/30/141402
スマホ不要のスマートウォッチSmartGear。単体通話もできてSIMフリー
- SIMカードを内蔵することができる、通話だけでなくスマホアプリもインストールできる.
- 本体にSIMカードを挿入できる.格安SIMも使用可能
- Android Wearでなく、Android OS Google Playにも対応
- 心拍数対応してないっぽい
AppleWatchのようなのはない
Podfileの書き方変わったし、Podfileをきれいにまとめて書く。
Podfileの書き方変わったし、Podfileをきれいにまとめて書く。
cocoapodsのversion 1.0にupdateしたついでにPodfileを書き換える。
Podfileの書き方が変わるので、Podfileを作り直す。 ( pod 'PromiseKit', '3.0.1'....のあたりは別でコピーとっておくんやで。)
rm -rf Podfile pod init
ターゲットいっぱいあるので
target 'ProjectName-iOS-AdHoc' do end
がいっぱいある。
複数のターゲットに同じPodをインストールする際に何度も書くのはよろしくない。(コピー漏れしそうだし。)
PodfileはRubyで書かれてるということが分かればきれいに書ける。
共通部分は定数にまとめて、各ターゲットはその定数をinstall。
# Uncomment this line to define a global platform for your project platform :ios, '9.0' use_frameworks! # インストールするpodをまとめた定数 def install_pods pod 'PromiseKit', '3.0.1' pod 'FrameAccessor', '2.0' pod 'LUKeychainAccess', '1.2.5' ........ end # あとは定数をinstall target 'ProjectName-iOS-AdHoc' do install_pods end target 'ProjectName-iOS-AdHocRelease' do install_pods end target 'ProjectName-iOS-Debug' do install_pods end target 'ProjectName-iOS-Release' do install_pods end target 'ProjectName-iOS-Store-AdHoc' do install_pods end target 'ProjectName-iOS-Store-Debug' do install_pods end target 'ProjectName-iOS-Store-Release' do install_pods end
参考 qiita.com
↑だと
def install_pods do end
になってるけど、
syntax error, unexpected keyword_end, expecting end-of-input.
でて怒られたんだけど、
def install_pods end
でOK。 定数宣言だしね、
[mac]iTerm2をupdateしたらgo2shellが現在ディレクトリに移動してくれなくなったのでapplescriptに乗り換えた
iTerm2をupdateしたらgo2shellが現在ディレクトリに移動してくれなくなったのでapplescriptに乗り換えた
今まではgo2shellというアプリをインストールしてFinderのツールバーに常駐させて使っていたのですが、iTermをアップデートしたタイミングで、go2shellしてiTermを開くとホームディレクトリで開かれるようになってしまった。
Finderで見てるカレントディレクトリに行ってくれるべんり君だったのに...
代替アプリを探してたらautometerやapplescriptでできるみたいだったので、何個か記事見た結果applescriptのが良さそうだったので参考にさせていただきました。
applescriptを開いて
tell application "iTerm" activate end tell tell application "Finder" set _dir to POSIX path of ((folder of (front window)) as alias) end tell tell application "iTerm" activate set _current_session to current session of current window tell _current_session write text "cd \"" & _dir & "\"" end tell end tell
上記コードをコピペ。
「iTermを開く」とかで「アプリケーション」として保存。
これで、Finderで見ている時にiTermを開きたくなったらこのファイルを実行すれば、iTermでカレントディレクトリを開いてくれます。
Finderツールバーに追加するには、保存したファイルをcmd+ドラッグでツールバーの上に持っていけばツールバーに追加され実行ファイル探さなくていいのでラクです。
こんな感じで追加出来ます。
まだgo2shellが右に生きてますが...
参考
node.jsでserver を立てる時のメモ
node.jsでserver を立てる時のメモ
// get module var http = require('http'); // create server var server = http.createServer(); // binding event server.on('request', function(req, res){ // req status code = 200 // これからわたすコンテンツのタイプ res.writeHead(200, {'Content-Type':'text/plain'}); // わたすもの res.write('hello world'); res.end(); }); // 待ち受け状態に 1337はポート番号 server.listen(5000, "127.0.0.1"); console.log("server listenning...");
deferの使いドコロ
deferの使いドコロ
swift2.0から追加された、deferってあまり使ってなかったんですがjavaとかのtry catch finallyのfinally的なやつだと思えば結構使えるやつなんですね。
// インジケータをグルグルさせる indicator?.startAnimating() // 二重タップ防止の為通信終わるまでボタン押せなくしておく 通信ボタン.userInteractionEnabled = false なんか通信とか { [weak self] (response) in // スコープ抜けるときに必ずやる処理 defer { // インジケータの止め忘れとか self?.indicator?.stopAnimating() // ボタン効かなくなったままにならないように 通信ボタン.userInteractionEnabled = true } if response.isOk { // レスポンスの処理とか } }
finallyと違って、同じスコープに複数書くこともできるみたいですね。
共通系CustomTableViewCell
## 共通系CustomTableViewCell
tableViewでCellに値をセットするとき、
cell.typeLabel.text = model.title cell.moneyLabel.text = model.money if let money = model.money where money > 0 { cell.moneyLabel.textColor = UIColor.BlueColor() } else { cell.moneyLabel.textColor = UIColor.RedColor() } cell.term.text = model.term cell.memo.text = model.memo
こんな感じで書いてたんですが、
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {}が膨れ上がってしまうので、cellの個々の値はちゃんとcell側で書いてあげた方がいいですね。
TableView側でモデルを渡してあげる
cell.model = model
CustomCell側
// 渡されたmodelを元に個々の要素に値をセットしていく var model: CellModel? { didSet { cellTitleLabel.text = { if let title = model?.title { return title } return "" }() moneyLabel.text = { if let money = model?.money { return money } return "0" }() if let money = model?.money where money > 0 { cell.moneyLabel.textColor = UIColor.BlueColor() } else { cell.moneyLabel.textColor = UIColor.RedColor() } term.text = model?.term memo.text = model?.memo } }
UILabelに行間をつける
上下余白のLabelと行間をつけるLabel
iOSアプリでヒラギノ角ゴを使っているとUILael に上下余白を付けないとjやgの下が切れちゃいますね。
(ちなみにベトナム語とかに対応する場合は、上にも長いので上下に余白つけると良いですね)
なのでよく上下paddingのラベルはUtilとして用意することはあると思います。
上下paddingのラベル
/* 行間のないただのヒラギノ角ゴ対策用の上下padding label */ class NoLineSpacePaddingLabel: UILabel { // paddingの値 let padding = UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2) override func drawTextInRect(rect: CGRect) { let newRect = UIEdgeInsetsInsetRect(rect, padding) super.drawTextInRect(newRect) } override func layoutSubviews() { super.layoutSubviews() // numberOfLines = customNumberOfLines } override func intrinsicContentSize() -> CGSize { var intrinsicContentSize = super.intrinsicContentSize() intrinsicContentSize.height += padding.top + padding.bottom intrinsicContentSize.width += padding.left + padding.right return intrinsicContentSize } }
しかし、これが複数行になった場合、一番上と一番下にしか余白が付きません。
この場合、frameの上下に余白をつけるより、行そのものに余白を付けるやり方のほうが良さそうです。
行間に余白を付けるLabel
@IBDesignable class PaddingLabel: UILabel { @IBInspectable var customNumberOfLines: Int = 0 override var text: String? { didSet { if let text = text { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = self.textAlignment paragraphStyle.lineBreakMode = self.lineBreakMode // fontサイズとって行の高さに余白つけないと上下中央にならない paragraphStyle.minimumLineHeight = self.font.pointSize + 6 paragraphStyle.maximumLineHeight = self.font.pointSize + 6 let attributedText = NSMutableAttributedString(string: text) attributedText.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedText.length)) self.attributedText = attributedText } layoutIfNeeded() } } override func layoutSubviews() { super.layoutSubviews() numberOfLines = customNumberOfLines } }