teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

質問修正

2019/09/02 01:14

投稿

mita0
mita0

スコア40

title CHANGED
File without changes
body CHANGED
@@ -10,14 +10,50 @@
10
10
  ②JSONデータの受け渡し(tableviewのTapした箇所)
11
11
 
12
12
 
13
+ Googleと検索した際にforの中で「items」をループで取り出しています。
14
+ 「hosts」「googletest」など順にtableに出力されます。
15
+ tableで「hosts」をタップした時に「hosts内の情報」、「googletest」をタップした時に「googeltest」内の情報」を順番に出したいです。
13
16
 
14
17
 
15
-
16
-
17
18
  ※ JSONデータ https://api.github.com/search/repositories?q=%20Google
18
19
  (配列の中に連想配列があります)
20
+ 下記、JSON + searchBar.text!からの値になります。
19
21
 
20
22
 
23
+ "total_count": 553223,
24
+ "incomplete_results": false,
25
+ "items": [
26
+ {
27
+ "id": 21481439,
28
+ "node_id": "MDEwOlJlcG9zaXRvcnkyMTQ4MTQzOQ==",
29
+ "name": "hosts",
30
+ "full_name": "kelthuzadx/hosts",
31
+ "private": false,
32
+ "owner": {
33
+ "login": "kelthuzadx",
34
+ "id": 5010047,
35
+ "node_id": "MDQ6VXNlcjUwMTAwNDc=",
36
+ "avatar_url": "https://avatars0.githubusercontent.com/u/5010047?v=4",
37
+ "gravatar_id": "",
38
+ "url": "https://api.github.com/users/kelthuzadx",
39
+ "html_url": "https://github.com/kelthuzadx",
40
+ "followers_url": "https://api.github.com/users/kelthuzadx/followers",
41
+ "following_url": "https://api.github.com/users/kelthuzadx/following{/other_user}",
42
+ "gists_url": "https://api.github.com/users/kelthuzadx/gists{/gist_id}",
43
+ "starred_url": "https://api.github.com/users/kelthuzadx/starred{/owner}{/repo}",
44
+ "subscriptions_url": "https://api.github.com/users/kelthuzadx/subscriptions",
45
+ "organizations_url": "https://api.github.com/users/kelthuzadx/orgs",
46
+ "repos_url": "https://api.github.com/users/kelthuzadx/repos",
47
+ "events_url": "https://api.github.com/users/kelthuzadx/events{/privacy}",
48
+ "received_events_url": "https://api.github.com/users/kelthuzadx/received_events",
49
+ "type": "User",
50
+ "site_admin": false
51
+ },
52
+ "html_url": "https://github.com/kelthuzadx/hosts",
53
+ "description": ":statue_of_liberty:最新可用的google hosts文件。国内镜像:",
54
+
55
+
56
+
21
57
  ```
22
58
  ### 行ったこと
23
59
 

3

2019/09/02 01:14

投稿

mita0
mita0

スコア40

title CHANGED
File without changes
body CHANGED
@@ -6,10 +6,14 @@
6
6
  jsonデータ(items)を画面遷移で渡したいです。
7
7
 
8
8
  それにともなってやりたいことは以下の通りです。
9
- ①メンバ変数に定義
9
+ ①メンバ変数に定義(配列のデータを配列に格納したい)
10
10
  ②JSONデータの受け渡し(tableviewのTapした箇所)
11
11
 
12
12
 
13
+
14
+
15
+
16
+
13
17
  ※ JSONデータ https://api.github.com/search/repositories?q=%20Google
14
18
  (配列の中に連想配列があります)
15
19
 

2

p

2019/09/02 01:11

投稿

mita0
mita0

スコア40

title CHANGED
File without changes
body CHANGED
@@ -133,4 +133,64 @@
133
133
  }
134
134
  }
135
135
 
136
+ ```
137
+ ```
138
+
139
+ import UIKit
140
+
141
+ class ThirdViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
142
+
143
+ var hosts: [String] = []
144
+
145
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
146
+ return self.hosts.count
147
+ }
148
+
149
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
150
+ let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
151
+ cell.textLabel!.text = hosts[indexPath.row]
152
+ return cell
153
+ }
154
+
155
+
156
+ override func viewDidLoad() {
157
+ super.viewDidLoad()
158
+
159
+ }
160
+ override func didReceiveMemoryWarning() {
161
+ super.didReceiveMemoryWarning()
162
+ }
163
+
164
+ func back() {
165
+ self.navigationController?.popToRootViewController(animated: true)
166
+
167
+ }
168
+
169
+ @IBAction func byPerformSegue(_ sender: Any) {
170
+ self.performSegue(withIdentifier: "toSegueViewController", sender: nil)
171
+
172
+ }
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ //self.navigationController?.popViewController(animated: true)
182
+
183
+ /*
184
+ // MARK: - Navigation
185
+
186
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
187
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
188
+ // Get the new view controller using segue.destination.
189
+ // Pass the selected object to the new view controller.
190
+ }
191
+ */
192
+
193
+ }
194
+
195
+
136
196
  ```

1

2019/08/30 06:44

投稿

mita0
mita0

スコア40

title CHANGED
File without changes
body CHANGED
@@ -22,14 +22,8 @@
22
22
 
23
23
  ### 該当のソースコード
24
24
  ```ここに言語を入力### 該当のソースコード
25
- //
26
- // ViewController.swift
27
- // test0826.1
28
- //
29
- // Created by Kamitani on 2019/08/26.
30
- // Copyright © 2019 Kamitani. All rights reserved.
31
- //
32
25
 
26
+
33
27
  import UIKit
34
28
 
35
29
  class ViewController: UIViewController, UISearchBarDelegate, URLSessionDelegate, UITableViewDelegate, UITableViewDataSource {