質問編集履歴
1
コードの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,21 +1,35 @@
|
|
1
1
|
swift の self の意味は何ですか?
|
2
2
|
英語だと自分自身という意味ですが、自分は何を指していますか?
|
3
|
-
例えば以下のコードの場合のselfは
|
3
|
+
例えば以下のコードの場合の2つのselfはどういう意味ですか?
|
4
4
|
```Swift
|
5
|
-
class MyClass {
|
6
|
-
// インスタンスプロパティ
|
7
|
-
|
5
|
+
import UIKit
|
6
|
+
|
7
|
+
class ViewController: UIViewController, UITextFieldDelegate {
|
8
|
+
|
8
|
-
|
9
|
+
@IBOutlet weak var myTextField: UITextField!
|
9
10
|
|
11
|
+
|
10
|
-
|
12
|
+
override func viewDidLoad() {
|
13
|
+
super.viewDidLoad()
|
14
|
+
// myTextFieldのデリゲートになる
|
11
|
-
|
15
|
+
myTextField.delegate = self
|
12
16
|
}
|
13
17
|
|
18
|
+
// 改行が入力された(デリゲートメソッド)
|
19
|
+
func textFieldShouldReturn(textField: UITextField) -> Bool {
|
14
|
-
|
20
|
+
// キーボードを下げる
|
15
|
-
func hello(){
|
16
|
-
|
21
|
+
self.view.endEditing(true)
|
22
|
+
return false // 改行は入力しない
|
17
23
|
}
|
24
|
+
|
25
|
+
override func didReceiveMemoryWarning() {
|
26
|
+
super.didReceiveMemoryWarning()
|
27
|
+
// Dispose of any resources that can be recreated.
|
28
|
+
}
|
29
|
+
|
30
|
+
|
18
31
|
}
|
19
32
|
|
33
|
+
|
20
34
|
```
|
21
35
|
よろしくお願いします
|