質問編集履歴
6
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -204,7 +204,9 @@
|
|
204
204
|
|
205
205
|
var selectedUser: SearchRootVC!
|
206
206
|
|
207
|
+
// 以下letにて、エラー
|
208
|
+
|
207
|
-
let repo = selectedUser.repo[selectedUser.RepoToPass]
|
209
|
+
let repo = selectedUser.repo[selectedUser.RepoToPass] // Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
|
208
210
|
|
209
211
|
|
210
212
|
|
5
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -200,7 +200,7 @@
|
|
200
200
|
|
201
201
|
|
202
202
|
|
203
|
-
```
|
203
|
+
```Model
|
204
204
|
|
205
205
|
var selectedUser: SearchRootVC!
|
206
206
|
|
@@ -230,7 +230,7 @@
|
|
230
230
|
|
231
231
|
|
232
232
|
|
233
|
-
```
|
233
|
+
```VC
|
234
234
|
|
235
235
|
func setupUI() {
|
236
236
|
|
4
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -193,3 +193,57 @@
|
|
193
193
|
}
|
194
194
|
|
195
195
|
```
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
## 追記2 (現在状況)
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
```swift
|
204
|
+
|
205
|
+
var selectedUser: SearchRootVC!
|
206
|
+
|
207
|
+
let repo = selectedUser.repo[selectedUser.RepoToPass]
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
...
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
struct repoTxt {
|
216
|
+
|
217
|
+
static let language = "Written in (repo["language"] as? String ?? "")"
|
218
|
+
|
219
|
+
static let stars = "(repo["stargazers_count"] as? Int ?? 0) stars"
|
220
|
+
|
221
|
+
static let watchers = "(repo["wachers_count"] as? Int ?? 0) watchers"
|
222
|
+
|
223
|
+
static let forks = "(repo["forks_count"] as? Int ?? 0) forks"
|
224
|
+
|
225
|
+
static let issues = "(repo["open_issues_count"] as? Int ?? 0) open issues"
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
```
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
```swift
|
234
|
+
|
235
|
+
func setupUI() {
|
236
|
+
|
237
|
+
LanguageLbl.text = repoTxt.language
|
238
|
+
|
239
|
+
StarsLbl.text = repoTxt.stars
|
240
|
+
|
241
|
+
WatchersLbl.text = repoTxt.watchers
|
242
|
+
|
243
|
+
ForksLbl.text = repoTxt.forks
|
244
|
+
|
245
|
+
IssuesLbl.text = repoTxt.issues
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
```
|
3
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -178,6 +178,18 @@
|
|
178
178
|
|
179
179
|
|
180
180
|
|
181
|
-
|
181
|
+
もしくは、`init`を使用せず以下のように`static let`の使用も考えたのですが、
|
182
182
|
|
183
|
-
|
183
|
+
テキストデータのモデル格納に適切な方法は何でしょうか?
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
```model
|
188
|
+
|
189
|
+
struct Identifiers {
|
190
|
+
|
191
|
+
static let Language = "Written in (repo["language"] as? String ?? "")"
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
```
|
2
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,6 +130,54 @@
|
|
130
130
|
|
131
131
|
|
132
132
|
|
133
|
+
## 追記
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
以下のコードをクリーンアップしたいです。
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
`"Written in (repo["language"] as? String ?? "")"`以下5つのテキストデータを
|
142
|
+
|
143
|
+
**モデル**(別ファイル)に記述し、VCにて呼び出したいと考えています。
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
```VC
|
148
|
+
|
149
|
+
LanguageLbl.text = "Written in (repo["language"] as? String ?? "")"
|
150
|
+
|
151
|
+
StarsLbl.text = "(repo["stargazers_count"] as? Int ?? 0) stars"
|
152
|
+
|
153
|
+
WatchersLbl.text = "(repo["wachers_count"] as? Int ?? 0) watchers"
|
154
|
+
|
155
|
+
ForksLbl.text = "(repo["forks_count"] as? Int ?? 0) forks"
|
156
|
+
|
157
|
+
IssuesLbl.text = "(repo["open_issues_count"] as? Int ?? 0) open issues"
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
こんな感じです。
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
```VC
|
166
|
+
|
167
|
+
// LanguageLbl.text = repo.language
|
168
|
+
|
169
|
+
// StarsLbl.text = repo.stars
|
170
|
+
|
171
|
+
// WatchersLbl.text = repo.watchers
|
172
|
+
|
173
|
+
// ForksLbl.text = repo.folks
|
174
|
+
|
175
|
+
// IssuesLbl.text = repo.issues
|
176
|
+
|
177
|
+
```
|
178
|
+
|
179
|
+
|
180
|
+
|
133
181
|
質問は以上です。
|
134
182
|
|
135
183
|
お時間あるときに、ご返信頂けましたら幸いです????
|
1
あ
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Model内の、initの引数の書き方が分からないです【MVC】
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## Model内の、initの引数
|
2
2
|
|
3
3
|
|
4
4
|
|