1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift勉強日記 〜Part 1〜

Last updated at Posted at 2019-12-14

はじめに

やっとmacを手に入れたのでSwiftの勉強を始めました。
HackingWithSwiftのProject1を進めるにあたって今後のためにメモしておきたいと思ったことを綴ります。

コマンドのCheat Sheet

・Cmd + R : Simulatorの起動
・Cmd + . : Simulatorの終了
・Cmd + L : Libraryの表示

用語集

FileManager.default : ファイル操作をするために必要なデータタイプ。
Bundle : コンパイルされたプログラムや全ての要素を含むディレクトリである。
UITableViewController : スクロールや選択できる複数行のデータを表示できる。

データファイルの追加方法

データファイルを左側のNavigation AreaにDrag&Dropする。
スクリーンショット 2019-12-14 0.41.06.png

と以下の図のような画面が出現する。
スクリーンショット 2019-12-14 0.31.55.png

この際
・Copy items if needed
・Create groups
という項目がチェックされているか確認すること

ファイル名の取得方法

pathで取得したディレクトリ内のファイル名を全て取得する。

let path = Bundle.main.resourcePath!
let contents = FileManager.default.contentsOfDirectory(atPath: path)

列の表示方法

TableViewにおいて表示する列の数を設定する

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return //ここに表に表示させたい列の数
}

UITableViewControllerへの変更方法

まず

class ViewController: UIViewController 

class ViewController: UITableViewController 

に変更する。

次にMain.storyboard内において、デフォルトで設定されている View Controller Scene を Table View Controller に変更する。
スクリーンショット 2019-12-14 1.26.33.png

Navigation Controllerとは?

Table View Controller を Navigation Controller に Embed In すると、iPhoneの設定上部で見られる画面遷移のための Navigation Bar が表示される。
IMG_A41E31204DB4-1.jpeg

参考Webサイト
https://www.hackingwithswift.com/100

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?