なんとかするから、なんとかなる

エンジニア関係のことを書きます

English

Swift 4.2 How to get a all values of enum

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…

iOS How to solve the build error related with "CommonCrypto" on Xcode10

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…

How to connect to localhost on Mac from iPhone

Introduction This article shows how to connect to localhost on Mac from iPhone and some tips. Conditions Mac and iPhone is on the same network. How to connect it Set up the localhost server on a mac Confirm the access to the "localhost:{Po…

iOS How to change a language settings while debugging on the devices

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…

iOS UIPageViewController How to soleve the error message "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…

iOS How to set the Autolayout programatically

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, …

iOS How to copy the string to Clipboard

Solution let board = UIPasteboard.general board.string = "ABC"

iOS How to use the Decodable

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…

iOS How to wait for the async procedure in XCTest

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…

iOS How to solve the error message about Module was not compiled for testing

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…

iOS How to get an index of array in for each sentence.

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 }

iOS How to edit a View in debug mode by LLDB Console

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…

iOS How to detect the background transition in 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…

iOS How to solve the black screen when a modal view was dismissed with custom animation.

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…

iOS How to scale an image in UIButton.

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…

iOS How to get a monospace font for digits in UIFont.

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 …

iOS UITextField How to dismiss the keyboard when user tap a retrun key.

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…

iOS UITableView deleteRows(at:with:) was crashed

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…

iOS It’s difficult to animate UIView by themselves when it appeared.

Introduction This article explains its difficult to animate an UIView by themselves when it appeared. Conclusion There two solution for the problem. • Call some animation start method by UIViewController • Observe the didBecomeActive event…

iOS How to detect the instance is inheritance of some class or not.

Intoroduction This are article shows how to detect the instance is inheritance of some class or not. Solution if someInstane is SomeClass { // The Instance is inheritance of some class. } else { // Instance is not inheritance of some class.…

iOS How to detect an user interacion while animating

Introduction This article shows how to detect an user interaction while animating on UIView or UIbutton or etc. Solution Set the ".allowUserIntercation" properties in option at UIView.animate method. UIView.animate(withDuration: 1.0, delay…

iOS How to deselect a cell which was tapped by user.

Introduction This article shows how to deselect an cell when user tapped it. Solution It's a easy way to do it. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { //Change the selected background view …

iOS How to rotate a UIView in 360 degrees.

Introduction This article shows how to rotate360 degrees for UIView. First I thought of using UiView.animate method and AffineTransform the UIView. It was figured out that if I set a transform property as below view.transform = CGAffineTra…

iOS UIView transform doesn't scale propery while transition animetion.

Sorry for my poor English skill. Introduction This article shows how to solve the problem that UIView transform doesn't scale correctly while transition animation. Transition animation make an app interactively. But, sometimes it meka deve…