質問編集履歴
6
あ
title
CHANGED
File without changes
|
body
CHANGED
@@ -101,7 +101,8 @@
|
|
101
101
|
|
102
102
|
```Model
|
103
103
|
var selectedUser: SearchRootVC!
|
104
|
+
// 以下letにて、エラー
|
104
|
-
let repo = selectedUser.repo[selectedUser.RepoToPass]
|
105
|
+
let repo = selectedUser.repo[selectedUser.RepoToPass] // Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
|
105
106
|
|
106
107
|
...
|
107
108
|
|
5
a
title
CHANGED
File without changes
|
body
CHANGED
@@ -99,7 +99,7 @@
|
|
99
99
|
|
100
100
|
## 追記2 (現在状況)
|
101
101
|
|
102
|
-
```
|
102
|
+
```Model
|
103
103
|
var selectedUser: SearchRootVC!
|
104
104
|
let repo = selectedUser.repo[selectedUser.RepoToPass]
|
105
105
|
|
@@ -114,7 +114,7 @@
|
|
114
114
|
}
|
115
115
|
```
|
116
116
|
|
117
|
-
```
|
117
|
+
```VC
|
118
118
|
func setupUI() {
|
119
119
|
LanguageLbl.text = repoTxt.language
|
120
120
|
StarsLbl.text = repoTxt.stars
|
4
a
title
CHANGED
File without changes
|
body
CHANGED
@@ -95,4 +95,31 @@
|
|
95
95
|
struct Identifiers {
|
96
96
|
static let Language = "Written in (repo["language"] as? String ?? "")"
|
97
97
|
}
|
98
|
+
```
|
99
|
+
|
100
|
+
## 追記2 (現在状況)
|
101
|
+
|
102
|
+
```swift
|
103
|
+
var selectedUser: SearchRootVC!
|
104
|
+
let repo = selectedUser.repo[selectedUser.RepoToPass]
|
105
|
+
|
106
|
+
...
|
107
|
+
|
108
|
+
struct repoTxt {
|
109
|
+
static let language = "Written in (repo["language"] as? String ?? "")"
|
110
|
+
static let stars = "(repo["stargazers_count"] as? Int ?? 0) stars"
|
111
|
+
static let watchers = "(repo["wachers_count"] as? Int ?? 0) watchers"
|
112
|
+
static let forks = "(repo["forks_count"] as? Int ?? 0) forks"
|
113
|
+
static let issues = "(repo["open_issues_count"] as? Int ?? 0) open issues"
|
114
|
+
}
|
115
|
+
```
|
116
|
+
|
117
|
+
```swift
|
118
|
+
func setupUI() {
|
119
|
+
LanguageLbl.text = repoTxt.language
|
120
|
+
StarsLbl.text = repoTxt.stars
|
121
|
+
WatchersLbl.text = repoTxt.watchers
|
122
|
+
ForksLbl.text = repoTxt.forks
|
123
|
+
IssuesLbl.text = repoTxt.issues
|
124
|
+
}
|
98
125
|
```
|
3
あ
title
CHANGED
File without changes
|
body
CHANGED
@@ -88,5 +88,11 @@
|
|
88
88
|
// IssuesLbl.text = repo.issues
|
89
89
|
```
|
90
90
|
|
91
|
-
|
91
|
+
もしくは、`init`を使用せず以下のように`static let`の使用も考えたのですが、
|
92
|
-
|
92
|
+
テキストデータのモデル格納に適切な方法は何でしょうか?
|
93
|
+
|
94
|
+
```model
|
95
|
+
struct Identifiers {
|
96
|
+
static let Language = "Written in (repo["language"] as? String ?? "")"
|
97
|
+
}
|
98
|
+
```
|
2
a
title
CHANGED
File without changes
|
body
CHANGED
@@ -64,5 +64,29 @@
|
|
64
64
|
Cannot convert value of type '[String : Any]' to expected argument type 'Repository'
|
65
65
|
```
|
66
66
|
|
67
|
+
## 追記
|
68
|
+
|
69
|
+
以下のコードをクリーンアップしたいです。
|
70
|
+
|
71
|
+
`"Written in (repo["language"] as? String ?? "")"`以下5つのテキストデータを
|
72
|
+
**モデル**(別ファイル)に記述し、VCにて呼び出したいと考えています。
|
73
|
+
|
74
|
+
```VC
|
75
|
+
LanguageLbl.text = "Written in (repo["language"] as? String ?? "")"
|
76
|
+
StarsLbl.text = "(repo["stargazers_count"] as? Int ?? 0) stars"
|
77
|
+
WatchersLbl.text = "(repo["wachers_count"] as? Int ?? 0) watchers"
|
78
|
+
ForksLbl.text = "(repo["forks_count"] as? Int ?? 0) forks"
|
79
|
+
IssuesLbl.text = "(repo["open_issues_count"] as? Int ?? 0) open issues"
|
80
|
+
```
|
81
|
+
こんな感じです。
|
82
|
+
|
83
|
+
```VC
|
84
|
+
// LanguageLbl.text = repo.language
|
85
|
+
// StarsLbl.text = repo.stars
|
86
|
+
// WatchersLbl.text = repo.watchers
|
87
|
+
// ForksLbl.text = repo.folks
|
88
|
+
// IssuesLbl.text = repo.issues
|
89
|
+
```
|
90
|
+
|
67
91
|
質問は以上です。
|
68
92
|
お時間あるときに、ご返信頂けましたら幸いです????
|
1
あ
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
Model内の、initの引数の書き方が分からないです【MVC】
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## Model内の、initの引数
|
2
2
|
|
3
3
|
VCにて、コンパクトにテキストを表示するため、
|
4
4
|
Modelを使用したいです。
|