質問編集履歴
6
a
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
```
|
13
13
|
|
14
14
|
上記メッセージが出たのですが、**`RepositoryApi`のどこが不適切なのでしょうか?**
|
15
|
+
`self`を消すとエラーになるのですが..
|
16
|
+
|
15
17
|
以下にコードを記載します。
|
16
18
|
|
17
19
|
## コード
|
5
あ
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
Exception BreakPointでエラーを特定したが、不適切な箇所が分からない【EXC_BAD_ACCESS】
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## Exception BreakPointでエラーを特定したが、不適切な箇所が分からない
|
2
2
|
|
3
3
|
RUNすると画面が真っ白で、画面をタッチすると
|
4
4
|
`EXC_BAD_ACCESS (code=2, address=0x7ffee12bafc8)`エラーが出てしまいます。
|
4
a
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
EXC_BAD_ACCESSが出る。【
|
1
|
+
EXC_BAD_ACCESSが出る。【】
|
body
CHANGED
@@ -4,98 +4,51 @@
|
|
4
4
|
`EXC_BAD_ACCESS (code=2, address=0x7ffee12bafc8)`エラーが出てしまいます。
|
5
5
|
|
6
6
|
|
7
|
-
[**
|
7
|
+
[**こちら**](https://www.hfoasi8fje3.work/entry/2018/08/22/004804)を参考に
|
8
|
-
|
8
|
+
`Exception BreakPoint`を利用し、
|
9
9
|
|
10
|
-
|
10
|
+
```
|
11
|
-
|
11
|
+
self CodeCheck_Test_Yumemi.RepositoryApi 0x00007fd96f0220e0
|
12
|
+
```
|
12
13
|
|
14
|
+
上記メッセージが出たのですが、**`RepositoryApi`のどこが不適切なのでしょうか?**
|
13
|
-
|
15
|
+
以下にコードを記載します。
|
14
16
|
|
15
|
-
](b030681d475777c429d62b1c91b80aa3.png)
|
16
|
-
|
17
17
|
## コード
|
18
18
|
|
19
|
-
```
|
19
|
+
```RepositoryApi
|
20
20
|
import UIKit
|
21
21
|
|
22
|
-
class
|
22
|
+
class RepositoryApi: SearchRootVC {
|
23
|
+
|
23
|
-
|
24
|
+
func getRandomRepoUrlSession() {
|
25
|
+
|
24
|
-
|
26
|
+
let word = searchBar.text!
|
25
|
-
|
26
|
-
var word: String!
|
27
|
-
|
27
|
+
var url: String!
|
28
|
-
|
28
|
+
|
29
|
-
|
30
|
-
var task: URLSessionTask?
|
31
|
-
var repo: [[String: Any]]=[]
|
32
|
-
|
33
|
-
|
29
|
+
if word.count > 0 {
|
34
|
-
super.viewDidLoad()
|
35
|
-
|
36
|
-
|
30
|
+
url = URL_BASE + "(word)"
|
37
|
-
|
38
|
-
|
31
|
+
let task = URLSession.shared.dataTask(with: URL(string: url)!) { (data, res, err) in
|
32
|
+
|
39
|
-
|
33
|
+
guard err == nil else {
|
40
|
-
|
34
|
+
debugPrint(err.debugDescription)
|
35
|
+
return
|
41
|
-
|
36
|
+
}
|
42
|
-
|
43
|
-
|
37
|
+
|
44
|
-
|
38
|
+
if let obj = try! JSONSerialization.jsonObject(with: data!) as? [String: Any] {
|
39
|
+
if let items = obj["items"] as? [[String: Any]] {
|
40
|
+
self.repo = items
|
41
|
+
DispatchQueue.main.async {
|
45
|
-
|
42
|
+
self.tableView.reloadData()
|
46
|
-
return true
|
47
|
-
|
43
|
+
}
|
48
|
-
|
49
|
-
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
|
50
|
-
task?.cancel()
|
51
|
-
|
44
|
+
}
|
52
|
-
|
53
|
-
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
|
54
|
-
// getRandomRepoUrlSession()を実行する処理をかきたい。
|
55
|
-
|
45
|
+
}
|
56
|
-
|
57
|
-
|
58
|
-
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
59
|
-
if segue.identifier == Segues.ToProfileDetail {
|
60
|
-
if let detailVC = segue.destination as? ProfileDetailVC {
|
61
|
-
detailVC.selectedUser = self
|
62
46
|
}
|
47
|
+
// これ呼ばなきゃリストが更新されません
|
48
|
+
task.resume()
|
63
49
|
}
|
64
|
-
}
|
65
|
-
}
|
66
50
|
|
67
|
-
// extension
|
68
|
-
|
69
|
-
// UITableViewDelegate や UITableViewDataSource への適合は不要。
|
70
|
-
// 必要なプロトコルは、UITableViewController にて既に採用されているため。
|
71
|
-
|
72
|
-
extension SearchRootVC {
|
73
|
-
|
74
|
-
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
75
|
-
return repo.count
|
76
51
|
}
|
77
|
-
|
78
|
-
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
79
|
-
|
80
|
-
// dequeueReusableCellで、セルを再利用。
|
81
|
-
// nilを返さない為、オプショナルバインディングは不要。
|
82
|
-
|
83
|
-
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: Identifiers.RepositoryCell, for: indexPath) as! RepositoryCell
|
84
|
-
let rp = repo[indexPath.row]
|
85
|
-
// Any から Stringへ、より具体的な型にダウンキャスト。
|
86
|
-
// ダウンキャストに失敗し、nilとなると「""」。
|
87
|
-
// ??は、Nil結合演算子。
|
88
|
-
|
89
|
-
cell.textLabel?.text = rp[ApiKey.FullName] as? String ?? ""
|
90
|
-
cell.detailTextLabel?.text = rp[ApiKey.Language] as? String ?? ""
|
91
|
-
cell.tag = indexPath.row
|
92
|
-
return cell
|
93
|
-
}
|
94
|
-
|
95
|
-
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
96
|
-
RepoToPass = indexPath.row
|
97
|
-
performSegue(withIdentifier: Segues.ToProfileDetail, sender: self)
|
98
|
-
}
|
99
52
|
}
|
100
53
|
|
101
54
|
```
|
3
a
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,6 +7,13 @@
|
|
7
7
|
[**Xcodeでデバッグ実行中にクラッシュした時に捗るブレークポイント設定**](https://qiita.com/mono0926/items/bf70c7ef15db046ee163)を参考に、
|
8
8
|
**Add Exception BreakPoint**を探してみたのですが、それもありません。
|
9
9
|
|
10
|
+
自分のXcode↓
|
11
|
+

|
12
|
+
|
13
|
+
これが無い
|
14
|
+
|
15
|
+
](b030681d475777c429d62b1c91b80aa3.png)
|
16
|
+
|
10
17
|
## コード
|
11
18
|
|
12
19
|
```SearchRootVC
|
2
あ
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
EXC_BAD_ACCESSが出る。【Add Exception BreakPointが無い..】
|
body
CHANGED
@@ -4,11 +4,9 @@
|
|
4
4
|
`EXC_BAD_ACCESS (code=2, address=0x7ffee12bafc8)`エラーが出てしまいます。
|
5
5
|
|
6
6
|
|
7
|
+
[**Xcodeでデバッグ実行中にクラッシュした時に捗るブレークポイント設定**](https://qiita.com/mono0926/items/bf70c7ef15db046ee163)を参考に、
|
7
|
-
**
|
8
|
+
**Add Exception BreakPoint**を探してみたのですが、それもありません。
|
8
|
-
以下のコードのどこが原因なのでしょうか?
|
9
9
|
|
10
|
-
大雑把な質問になってしまい恐縮ですが、ご返信頂けますと嬉しいです。
|
11
|
-
|
12
10
|
## コード
|
13
11
|
|
14
12
|
```SearchRootVC
|
1
a
title
CHANGED
File without changes
|
body
CHANGED
@@ -24,9 +24,7 @@
|
|
24
24
|
|
25
25
|
var task: URLSessionTask?
|
26
26
|
var repo: [[String: Any]]=[]
|
27
|
-
|
28
|
-
|
27
|
+
|
29
|
-
|
30
28
|
override func viewDidLoad() {
|
31
29
|
super.viewDidLoad()
|
32
30
|
|