回答編集履歴
1
追記
answer
CHANGED
@@ -18,4 +18,43 @@
|
|
18
18
|
|
19
19
|
}
|
20
20
|
|
21
|
-
```
|
21
|
+
```
|
22
|
+
|
23
|
+
おまけ
|
24
|
+
---
|
25
|
+
SecondViewにnumberプロパティを持たせたやり方
|
26
|
+
(1ファイル分(AppDelegate)影響範囲が狭まった)
|
27
|
+
```swift
|
28
|
+
// ViewController
|
29
|
+
|
30
|
+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
31
|
+
|
32
|
+
let storyboard: UIStoryboard = self.storyboard!
|
33
|
+
let nextView = storyboard.instantiateViewController(withIdentifier: "second") as! SecondViewController
|
34
|
+
|
35
|
+
nextView.number = indexPath.row
|
36
|
+
|
37
|
+
self.present(nextView, animated: true, completion: nil)
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
```
|
42
|
+
```swift
|
43
|
+
class SecondViewController: UIViewController {
|
44
|
+
|
45
|
+
@IBOutlet weak var Label: UILabel!
|
46
|
+
|
47
|
+
var number:Int?
|
48
|
+
|
49
|
+
override func viewDidLoad() {
|
50
|
+
super.viewDidLoad()
|
51
|
+
|
52
|
+
// Do any additional setup after loading the view.
|
53
|
+
|
54
|
+
Label.text = "\(number)"
|
55
|
+
}
|
56
|
+
// 略
|
57
|
+
}
|
58
|
+
|
59
|
+
```
|
60
|
+
しかし、サイトがクソ重いな...
|