Swift
Introduction This article shows how to use "CaseIterable" protocol which introduced in Swift4.2. This protocol can provede all values of enum type. So, I do not need to implement such a property any more. Before Swift4.2 In Swift4.1 or ear…
English version below https://hopita.hatenablog.com/entry/2019/01/02/195204 はじめに オブジェクトの状態を定義など、いろいろと便利な列挙型Enumですが、この度Swift4.2で新しい機能が追加されていました。 この記事にはSwift 4.2からの新機能、列挙型…
Introduction This article shows how to solve the build error related with "CommonCrypto" on Xcode10. After updating the Xcode to version10, I faced on the error messages as below. The CommonCrypto was imported by cocoapods in my case. Rede…
English version below https://hopita.hatenablog.com/entry/2018/09/30/154646 はじめに Xcode10来ましたね。 早速アップデートしてみると次のようなエラー。 CocoaPodsとかで、モジュールをプロジェクトに組み込んでいると出会いやすいっぽいです。 Redef…
Introduction This article shows how to change a language settings while debugging on the devices. This method is useful for confirming the localized String or text including line breaks. It won't need to change the language from settings a…
English version is below. https://hopita.hatenablog.com/entry/2018/09/12/220856 はじめに 実機でデバッグ時に言語設定したい。 ローカライズがきちんとできているか、改行が正しくできているかなど確認するときに便利な方法です。 いちいちデバイス言語…
English version below https://hopita.hatenablog.com/entry/2018/09/09/091925 はじめに UIPageViewControllerを早送りしたときに次のようなエラーが出ました。 Unbalanced calls to begin/end appearance transitions for そのときのコードはこんな感じで…
Introduction When I tried to transition some pages so rapidly. The Xcode shows an error message as below. Unbalanced calls to begin/end appearance transitions for The code is below. class MyPageViewController: UIPageViewController { var ma…
Introduction It was difficult and complexity to set the autolayout programatically when the AutoLyaout announced in iOS NSLayoutConstraint(item: button, attribute: .leading, relatedBy: .equal, toItem: self.view, attribute: .leadingMargin, …
English version below https://hopita.hatenablog.com/entry/2018/09/06/204428 はじめに AutoLayoutが発表された当初、AutoLayoutをコードから設定するのは面倒でした。 NSLayoutConstraint(item: button, attribute: .leading, relatedBy: .equal, toItem…
Solution let board = UIPasteboard.general board.string = "ABC"
解決方法 ものすごく簡単です。 let board = UIPasteboard.general board.string = "あいうえお"
Introdution This article show the basically usage of Decodable Protocol. What's the Decodable The Decodable give us an easy way to convert the JSON Data type to Class or Struct. Thanks for the Decoable protocol, developer could access each…
English version below https://hopita.hatenablog.com/entry/2018/09/02/110756 はじめに 今回はSwift4 で追加されたDecodableの使い方について紹介します。 Decodableとは API Requestなどで返ってくるJSONのData型を任意のクラスや構造体に変換する際に便…
Introduction This article shows how to wait for an async procedure like API Request or some closure. Solution It is easy to wait an async procedure using "expectation" Sample Code let request = SomeRequest() let expect = expectation(descri…
English version below https://hopita.hatenablog.com/entry/2018/09/01/110533 はじめに タイトル通りです。 APIRequestなどXCTestで疎通確認をした際に、非同期処理の完了を待ちたいことはよくあります。 その方法を簡単に紹介 解決方法 expectationを使…
Introduction This article shows how to solve the error message about “Module was not compiled for testing” on XCTest code. The module was installed by Carthage. Background When I try to do my test code on the XCTest, sometimes I would like…
English version below https://hopita.hatenablog.com/entry/2018/08/29/202132 はじめに XCTestでユニットテストを実行し用としたときにぶつかった問題です。 Carthageでモジュールを導入し、ユニットテストでそのモジュールを使用するときに少しつまづき…
English version below https://hopita.hatenablog.com/entry/2018/08/27/210911 はじめに ForEach文でIndex番号が欲しいことはよくあるので、備忘録です。 解決方法 enumerated()メソッドを利用する for (index, value) in someArray.enumarated() { // な…
Introduction This article shows how to get an index in for each sentence. Solution Using enumarated method. You can get the index of array for (index, value) in someArray.enumarated() { // do something }
Introduction This article shows how to edit a view in debug mode by LLDB Console. Preparation First of all, Build an app on a simulator or device and open the [Debug View Hierarchy] In this article, I'll show you how to change an informati…
English version below. https://hopita.hatenablog.com/entry/2018/08/25/201940 はじめに UIViewControllerにおいて、アプリがバックグラウンドなったときやバックグラウンドに戻ってきたときに処理を行いことはよくあります。 今回はそのやり方を紹介した…
Introduction This article shows hot to detect an entering background and activating from background in UIViewController. Solution As you know, UIViewController doesn't have a delegate which is called when it will go background and come bac…
English version below https://hopita.hatenablog.com/entry/2018/08/25/203726 はじめに 今回はデバッグ中にLLDBでViewを操作するために役立つTipsを紹介します。 準備 デバッグを開始して、[Debug View Hierarchy]を開いておきます。 今回はUILabelの情報…
Introduction This article shows how to solve the black screen when a modal view was dismissed with custom animation. When I tried to set an present and modal animation when a modal view was appeared and disappeared. Though the present anim…
English Version below https://hopita.hatenablog.com/entry/2018/08/23/212747 はじめに UIViewControllerのモーダル表示presentメソッドに独自アニメーションをつけたら、dismiss時に画面が黒くなった(ブラックアウトした)ときの対処方法です。 UIViewC…
Introduction This article shows how to scale an image in UIButton. When UIButton will be a large scale or small scale by Autolayout engine, an image it was contained in the UIButton is not correspond to the scale normally. This article wil…
Intoduction This article shows how to set a monospace font for digits. A monospace font has same width in each character. Sometimes, a font which isn't monospace make the design baddly. Solution To get the monospace font for digits, Apple …
Introduction This article show you that how to dismiss the keyboard when user tap a return key on UITextField of iOS. In fact, this way shows on the iOS SDK document. I've never knew it. Solution Adapt the UITextFieldDelegate on your ViewC…
Introdution UITableView is one of the most popular UI system in iOS developer. But, sometimes this UI system make us annoying. In this time, when I try to delete the UITableViewCell from swipe or delete button, it would be crashed. So, thi…