| ... | @@ -28,6 +28,9 @@ Alert(title: "タイトル", message: "メッセージ", buttons: [ |
... | @@ -28,6 +28,9 @@ Alert(title: "タイトル", message: "メッセージ", buttons: [ |
|
|
// ボタンをタップした時
|
|
// ボタンをタップした時
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
},
|
|
},
|
|
|
|
.destrucive("削除") { // 警告表示(赤色)
|
|
|
|
// ...
|
|
|
|
},
|
|
|
.cancel("キャンセル") // action処理を省略すると、何もしない(UIを閉じるだけ)
|
|
.cancel("キャンセル") // action処理を省略すると、何もしない(UIを閉じるだけ)
|
|
|
]).show(from: self) // 画面に表示
|
|
]).show(from: self) // 画面に表示
|
|
|
|
|
|
| ... | @@ -36,6 +39,9 @@ ActionSheet(title: "タイトル", message: "メッセージ", buttons: [ |
... | @@ -36,6 +39,9 @@ ActionSheet(title: "タイトル", message: "メッセージ", buttons: [ |
|
|
.default("OK") {
|
|
.default("OK") {
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
},
|
|
},
|
|
|
|
.destrucive("削除") { // 警告表示(赤色)
|
|
|
|
// ...
|
|
|
|
},
|
|
|
.cancel("キャンセル")
|
|
.cancel("キャンセル")
|
|
|
]).show(from: self)
|
|
]).show(from: self)
|
|
|
```
|
|
```
|
| ... | @@ -93,13 +99,89 @@ Blur( |
... | @@ -93,13 +99,89 @@ Blur( |
|
|
)
|
|
)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
### 通知
|
|
|
|
App内で通知を表示
|
|
|
|
|
|
|
|
```swift
|
|
|
|
postLocalNotification(
|
|
|
|
title: "タイトル",
|
|
|
|
message: "メッセージ",
|
|
|
|
userInfo: [:] // 追加情報。UNMutableNotificationContent参照。
|
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
### TableView
|
|
### TableView
|
|
|
|
|
|
|
|
|
対象の行の`didSelectRowAt`Delegateを実行する。
|
|
|
|
```swift
|
|
|
|
// UITableView内で
|
|
|
|
performDidSelect(rowAt: /*対象(IndexPath)*/)
|
|
|
|
```
|
|
|
|
|
|
|
|
|
#### IndexPath Extensions
|
|
|
|
|
|
|
|
|
```swift
|
|
|
|
// 次の行のIndexPath
|
|
|
|
let next: IndexPath = indexPath.nextRow
|
|
|
|
|
|
|
|
// 前の行のIndexPath。すでに一番前の場合はnilを返す。
|
|
|
|
let prev: IndexPath? = indexPath.prevRow
|
|
|
|
```
|
|
|
|
|
|
|
|
## IO
|
|
## IO
|
|
|
|
|
|
|
|
|
### HTTP通信
|
|
|
|
|
|
|
|
#### GET
|
|
|
|
```swift
|
|
|
|
let params: [String:String?] = [
|
|
|
|
"Key": "Value"
|
|
|
|
]
|
|
|
|
GngHttp.get(url: /*URL*/, params: params) { data: Data?, response: URLResponse?, error: Error? in
|
|
|
|
// 通信後の処理
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### POST
|
|
|
|
POSTもGETとほぼ同じ。
|
|
|
|
```swift
|
|
|
|
let params: [String:String?] = [
|
|
|
|
"Key": "Value"
|
|
|
|
]
|
|
|
|
GngHttp.post(url: /*URL*/, params: params) { data: Data?, response: URLResponse?, error: Error? in
|
|
|
|
// 通信後の処理
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Muli-part
|
|
|
|
ファイルのアップロードなどは`multi-part`データで`POST`しなければならない。
|
|
|
|
|
|
|
|
```swift
|
|
|
|
let params: [String:Any] = [
|
|
|
|
"Key_str": "Value", // 文字列
|
|
|
|
"upload_img": image, // 画像(UIImage)
|
|
|
|
"key_data", data, // Data型
|
|
|
|
]
|
|
|
|
|
|
|
|
public static func postMultipart(
|
|
|
|
url: /*URL*/,
|
|
|
|
params: params,
|
|
|
|
makeFileName: { key in
|
|
|
|
switch key {
|
|
|
|
case "upload_img": return "sample.jpg"
|
|
|
|
default: return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) { data: Data?, response: URLResponse?,
|
|
|
|
// 通信後の処理
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
## データ処理
|
|
## データ処理
|
|
|
|
|
|
|
|
|
### CSV
|
|
|
|
|
|
|
|
### JSON
|
|
|
|
|
|
|
## Utils |
|
## Utils |
|
|
|
\ No newline at end of file |