質問編集履歴
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -184,6 +184,148 @@
|
|
184
184
|
|
185
185
|
```
|
186
186
|
|
187
|
+
### 2/25追記
|
188
|
+
|
189
|
+
```ここに言語を入力
|
190
|
+
|
191
|
+
import UIKit
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
var aText:Int = 0
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
class addViewController: UIViewController {
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
@IBOutlet weak var textField: UITextField!
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
override func viewDidLoad() {
|
210
|
+
|
211
|
+
super.viewDidLoad()
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
// textFieldの入力方法をナンバーパッドに設定
|
216
|
+
|
217
|
+
textField.keyboardType = UIKeyboardType.numberPad
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
override func viewDidAppear(_ animated: Bool) {
|
230
|
+
|
231
|
+
super.viewDidAppear(animated)
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
if let _ = UserDefaults.standard.object(forKey: "textKey") as? Int {
|
236
|
+
|
237
|
+
aText = (UserDefaults.standard.object(forKey: "textKey") as! Int)
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
@IBAction func addButton(_ sender: Any) {
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
let textB = Int(textField.text!)
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
aText = aText + textB!
|
260
|
+
|
261
|
+
UserDefaults.standard.set(String(aText), forKey: "textKey")
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
```
|
274
|
+
|
275
|
+
```ここに言語を入力
|
276
|
+
|
277
|
+
import UIKit
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
class ViewController: UIViewController {
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
@IBOutlet weak var label: UILabel!
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
override func viewDidLoad() {
|
292
|
+
|
293
|
+
super.viewDidLoad()
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
override func viewDidAppear(_ animated: Bool) {
|
308
|
+
|
309
|
+
super.viewDidAppear(animated)
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
if let _ = UserDefaults.standard.object(forKey: "textKey") as? String {
|
314
|
+
|
315
|
+
label.text = (UserDefaults.standard.object(forKey: "textKey") as! String)
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
```
|
328
|
+
|
187
329
|
|
188
330
|
|
189
331
|
### 試したこと
|