うちのいぬ Tech Blog

Tech Blog of Uchinoinu/My dog

How to execute some methods at regular intervals like clock

Call NSTimer.scheduledTimerWithTimeInterval( 1, // second target: self, selector: #selector(ThisClass.methodName), userInfo: nil, repeats: true ) Execute func methodName() { print("pikachu!") } In UIViewController override func viewDidLoad…

時計の様に、ある関数を定期的に実行する様な仕組み

呼び出し方 NSTimer.scheduledTimerWithTimeInterval( 1, // 単位は秒で間隔を指定 target: self, selector: #selector(ThisClass.methodName), userInfo: nil, repeats: true ) 実行 func methodName() { print("pikachu!") } UIViewControllerでやるなら o…

Get weekday String from NSDate by Swift

Easy way class func weekdayFromNSDate(date: NSDate) -> String { let cal = NSCalendar.currentCalendar() let comp = cal.components(NSCalendarUnit.Weekday, fromDate: date) let weekdayIndex = comp.weekday let formatter: NSDateFormatter = NSDat…

SwiftでNSDateから曜日を求める方法

割りと楽なやり方 class func weekdayFromNSDate(date: NSDate) -> String { let cal = NSCalendar.currentCalendar() let comp = cal.components(NSCalendarUnit.Weekday, fromDate: date) let weekdayIndex = comp.weekday let formatter: NSDateFormatter…

Morning Study Time Again!

This is 4th morning study time of Swift! Morning Study, which is "Asakatsu" in Japanese, is my favorite style of studying. But these days I had not able to have enough time to it. This time, relaxing and studying is my most important conce…

朝活みたいな感じで、Swiftをもくもく勉強するのを再開してみた!

実は第4回目になります。 朝活は暫く出来ていなかったので、ちゃんと、ゆる〜くやろうと思います。 以前はスタバでやっていてとっても快適だったのですが、今は自宅で。 今回は↓な感じでログを残しながら進めていきます。 ログ ディレクトリ構成は帰るかも …

In Wercker, error "Bundler failing with index file .idx too small error" is show up

Situation Using Wercker for Building and Deploying Rails 4.x application. The Wercker version is Docker. In the build step, Bundler failing with index file .idx too small error error above is occurred so many times. and in the end, Retry e…

Werckerで "Bundler failing with index file .idx too small error" といったエラーが出た場合の対処

状況 普段Rails4系のアプリでWerckerをCIとして使っています。 WerckerはDocker版を使用しています。 そのBuild Stepで Bundler failing with index file .idx too small error といったエラーがたくさんでて、結果的に Retry exceeds max retries といった…

Git command for Deploy or PR merging

Diff of changed files $ git diff --stat commit-new commit-old $ git diff --stat --name-only commit-new commit-old $ git diff --stat --ignore-blank-lines commit-new commit-old Diff of content of file $ git diff commit-old commit-new -- path…

デプロイ前のログや差分をチェックするgitコマンド

変更したfileの抽出 $ git diff --stat commit-new commit-old $ git diff --stat --name-only commit-new commit-old $ git diff --stat --ignore-blank-lines commit-new commit-old fileの変更差分 $ git diff commit-old commit-new -- path/to/file 差…

Links of Restful API(JSON) References

Japanese Here uchinoinu.hatenablog.jp Guideline github.com github.com Platform developer.yahoo.co.jp RESTful Web サービスの基本 Articles qiita.com www.toptal.com 10 Best Practices for Better RESTful API | Thinking Mobile Presentation www.i…

Restful API(JSON)の参考まとめ

Japanese here uchinoinu.hatenablog.jp Guideline github.com github.com Platform developer.yahoo.co.jp RESTful Web サービスの基本 Articles qiita.com www.toptal.com 10 Best Practices for Better RESTful API | Thinking Mobile Presentation www.i…

How to set initial selected tab

Japanese here uchinoinu.hatenablog.jp func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { let tabBar = self.window!.rootViewController as! UITabBarController tabBar.se…

最初に選択されるTabを指定する方法

English here uchinoinu.hatenablog.jp func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { let tabBar = self.window!.rootViewController as! UITabBarController tabBar.sel…

rails c(bin/rails c) cannot load env vars managed by direnv

Japanese here uchinoinu.hatenablog.jp Situation Rails 4.2 Ruby 2.3 Spring 1.3.5 direnv 2.8.1 Manage environment variables by direnv run rails command using Spring Problem Adding new environment variables, rails c cannot load any environmen…

direnvで環境変数を管理していて、springへのpathも貼っている場合、環境変数を編集すると、rails cとかで環境変数が読み込めなくなるエラーへの対応

English here uchinoinu.hatenablog.jp 状況 Rails 4.2 Ruby 2.3 Spring 1.3.5 direnv 2.8.1 direnvで環境変数を管理している Springを使ってrailsコマンドを動かしている 問題 環境変数を追加したら、rails sは通るけど、rails cでは環境変数を読み込めなく…

How to embed css(sass) in Slim file

Japanese here. uchinoinu.hatenablog.jp sass: img width: 100% Write like above, <style type="text/css"> img { width: 100%; } </style> Output html like above. Reference マークアッパー的 Slim 入門21の手引き | e2esound.com業務日誌

Slimファイル内に css(sass)を埋め込む方法

English here uchinoinu.hatenablog.jp 簡単でした sass: img width: 100% と書くと <style type="text/css"> img { width: 100%; } </style> と出力されます。 Reference マークアッパー的 Slim 入門21の手引き | e2esound.com業務日誌

Show title to NavigationBar by Coding

Japanese here uchinoinu.hatenablog.jp Standard Way Set title property in NavigationItem of NavigationController self.navigationItem.title = "title" Popular Failure self.navigationController.title = "title" Rapid Way Set title property of U…

NavigationBarにtitleをコードで表示させる方法

English Here. uchinoinu.hatenablog.jp ちゃんとした方法 NavigationControllerのNavigationItemのtitleプロパティに設定する self.navigationItem.title = "title" よくある間違い self.navigationController.title = "title" 手っ取り早い方法 selfがUIVi…

How to handle Error: IBOutlet is nil in ViewController transited by code not by Segue.

Japanese version is here uchinoinu.hatenablog.jp Env Xcode 8.0 bata Swift 3 Situation Make UI using Storyboard Using IBOutlet Transition by Code Problem 遷移先でIBOutletさんがnilになります Reason I did wrong way to call ViewController to t…

Segueを使わず、コードで遷移した先のViewControllerでIBOutletがnilになるよってエラーが出る際の対応

English is here. uchinoinu.hatenablog.jp 環境 Xcode 8.0 bata Swift 3 状況 StoryboardでUIをつくちゃっている IBOutletを使っている せめて遷移にはSegueではなくコードを使う 問題点 遷移先でIBOutletさんがnilになります 原因 Segueを使わないので、遷…

How to handle Error: IBOutlet is nil in ViewController transited by code not by Segue.

Japanese version is here uchinoinu.hatenablog.jp Env Xcode 8.0 bata Swift 3 Principle to develop Make UI using Storyboard Using IBOutlet Transition by Code Problem 遷移先でIBOutletさんがnilになります Reason I did wrong way to call ViewCont…

Segueを使わず、コードで遷移した先のViewControllerでIBOutletがnilになるよってエラーが出る際の対応

状況 環境 Xcode 8.0 bata Swift 3 方針 StoryboardでUIをつくちゃっている IBOutletを使っている せめて遷移にはSegueではなくコードを使う 問題点 遷移先でIBOutletさんがnilになります 原因 Segueを使わないので、遷移にはコードを使っていました。 遷移…

Localization of iOS App - including Storyboard and plist

Japanese is here uchinoinu.hatenablog.jp I watched this view often. Now make the manual to localiztion Flow This time, I made localization env like below. - Base is English - add Japanese. 1. Generate Localizable.strings 2. Set up show fil…

アプリをローカライズ(国際化)する・Storyboardやplistも含め、複数言語を設定する

English is here uchinoinu.hatenablog.jp Webアプリではやったことあっても、iOSではなかったのですが、 ↓はよく目にしていました。 ちゃんと手順をおってみます。 手順 1. Localizable.stringsを作成 2. Localizeの設定 出来たファイルをinspector表示しま…

How to handle warning of Deleted File “file xxx is missing from working copy” at project building

Related to uchinoinu.hatenablog.jp Warning “file xxx is missing from working copy” at project building How This time, warning against to deleted file. Maybe cache of git is problem. $ git rm -r --cached .

存在しないファイル “file xxx is missing from working copy” at project building というWarningへの対応

↓と関連してます uchinoinu.hatenablog.jp Warning(警告) “file xxx is missing from working copy” at project building 対応 実際に存在しないファイルについてこういう警告がでたときは、Gitのcacheを消したらうまくいきました。 $ git rm -r --cached .

How to remove Warning "The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist"

Warning The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist'. Dealing Remove Info.plist from Copy Bundle Resources in Build Phase Reference Technical Q&A QA1649: WARNING: The Copy Bundle Resources build…

2016年上半期の振り返り

概要 2016年も半年が過ぎて、早7/3。 本当は毎日、毎週、毎月ちゃんと振り返りたかったけど、 まずは今日から始めたいと思います。 簡単なまとめ 心の成長?復活?が出来ました 好きなことを思い出して、またやれるようになった 自分の性質について少し理解で…