質問編集履歴

3

コードの追加

2017/03/13 08:44

投稿

mokumoku
mokumoku

スコア46

test CHANGED
File without changes
test CHANGED
@@ -128,6 +128,10 @@
128
128
 
129
129
  cachePolicy: .returnCacheDataElseLoad);
130
130
 
131
+ //追記
132
+
133
+ let urlStay = req.url
134
+
131
135
  let conf = URLSessionConfiguration.default;
132
136
 
133
137
  let session = URLSession(configuration: conf, delegate: nil, delegateQueue: OperationQueue.main);
@@ -138,7 +142,9 @@
138
142
 
139
143
  { (data, resp, err) in
140
144
 
145
+ //追記
146
+
141
- if((err) == nil){ //Success
147
+ if((err) == nil && urlStay == resp?.url){ //Success
142
148
 
143
149
  let image = UIImage(data:data!)
144
150
 

2

コードの追記

2017/03/13 08:44

投稿

mokumoku
mokumoku

スコア46

test CHANGED
File without changes
test CHANGED
@@ -110,6 +110,20 @@
110
110
 
111
111
 
112
112
 
113
+ override func setSelected(_ selected: Bool, animated: Bool) {
114
+
115
+ super.setSelected(selected, animated: animated)
116
+
117
+ }
118
+
119
+
120
+
121
+
122
+
123
+ func setCell(friend :Friend) {
124
+
125
+
126
+
113
127
  let req = URLRequest(url: NSURL(string:friend.imageUrl as String)! as URL,
114
128
 
115
129
  cachePolicy: .returnCacheDataElseLoad);
@@ -142,4 +156,8 @@
142
156
 
143
157
  }).resume();
144
158
 
159
+ }
160
+
161
+ }
162
+
145
163
  ```

1

コードの追記

2017/03/13 07:37

投稿

mokumoku
mokumoku

スコア46

test CHANGED
File without changes
test CHANGED
@@ -27,6 +27,62 @@
27
27
 
28
28
 
29
29
  何か、解決方法等がございましたら、ご教示お願い致します。
30
+
31
+
32
+
33
+ ```ここに言語を入力
34
+
35
+
36
+
37
+ import UIKit
38
+
39
+ import SwiftyJSON
40
+
41
+
42
+
43
+ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, URLSessionDelegate {
44
+
45
+
46
+
47
+ @IBOutlet weak var tableView: UITableView!
48
+
49
+
50
+
51
+ ~ 省略 ~
52
+
53
+
54
+
55
+ // セクション数
56
+
57
+ func numberOfSectionsInTableView(tableView: UITableView) -> Int {
58
+
59
+ return 1
60
+
61
+ }
62
+
63
+
64
+
65
+ // セクションの行数
66
+
67
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
68
+
69
+ return friends.count
70
+
71
+ }
72
+
73
+
74
+
75
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath:IndexPath) -> UITableViewCell {
76
+
77
+ let cell: CustomCell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath as IndexPath) as! CustomCell
78
+
79
+ cell.setCell(friend: friends[indexPath.row])
80
+
81
+ return cell
82
+
83
+ }
84
+
85
+ ```
30
86
 
31
87
 
32
88