String型の「2020/08/10」をDate型に変換したい。
import Foundation let dateFormatter = DateFormatter() dateFormatter.calendar = Calendar(identifier: .gregorian) dateFormatter.dateFormat = "yyyy/MM/dd" let date = dateFormatter.date(from: "2020/08/10") print(date!)
投稿日:
String型の「2020/08/10」をDate型に変換したい。
import Foundation let dateFormatter = DateFormatter() dateFormatter.calendar = Calendar(identifier: .gregorian) dateFormatter.dateFormat = "yyyy/MM/dd" let date = dateFormatter.date(from: "2020/08/10") print(date!)
執筆者:swift
関連記事
NavigationControllerでpopで前の階層を戻った時に値を渡す
NAvigationControllerで次の階層へ行く時に値を渡す方法と異なるので注意。 ひとつ前の階層のVCで受け取る変数を宣言しておく。 現在の階層で以下を記述する。 // 一つ前のViewCo …
collectionViewでセルが選択された時に色を変える
collectionViewでセルが選択された時にハイライトをつける関数。 collectionView(_:shouldHighlightItemAt:) デフォルトでtrueとなっているので、これ …
アラートを表示するメソッド //アラート func displayAleart() { let alert: UIAlertController = UIAlertController(title: …
PremiereProのメディアがオフラインになってる時のリンク方法
貰ったプロジェクトファイルを開こうとすると、素材がオフラインになってしまう。 メディアをリンクで、移動したファイルを検索して紐づける必要がある。 (オフライン=エラーになって素材が表示できない) &n …