質問編集履歴
1
基礎を見直すと解決できます。
test
CHANGED
File without changes
|
test
CHANGED
@@ -43,123 +43,3 @@
|
|
43
43
|
|
44
44
|
|
45
45
|
どなたか対処法をご存知の方、どうかご教授よろしくお願いします。
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
```ここに言語を入力
|
50
|
-
|
51
|
-
private var user: Results<User>!
|
52
|
-
|
53
|
-
private var tweets = Results<Tweet>?.self {
|
54
|
-
|
55
|
-
didSet { collectionView.reloadData() }
|
56
|
-
|
57
|
-
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
init(user: Results<User>!) {
|
62
|
-
|
63
|
-
self.user = user
|
64
|
-
|
65
|
-
super.init(collectionViewLayout: UICollectionViewFlowLayout())
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
|
-
```
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
```ここに言語を入力
|
74
|
-
|
75
|
-
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
76
|
-
|
77
|
-
let realm = try! Realm()
|
78
|
-
|
79
|
-
let tweetObject = realm.objects(Tweet.self)
|
80
|
-
|
81
|
-
return tweetObject.count
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
88
|
-
|
89
|
-
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! TweetCell
|
90
|
-
|
91
|
-
let tweetObject = tweets[indexPath.row]
|
92
|
-
|
93
|
-
cell.tweets = tweetObject
|
94
|
-
|
95
|
-
return cell
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
```
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
```ここに言語を入力
|
104
|
-
|
105
|
-
class User: Object {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@objc dynamic var id: Int = 0
|
110
|
-
|
111
|
-
@objc dynamic var fullname: String = ""
|
112
|
-
|
113
|
-
@objc dynamic var username: String = ""
|
114
|
-
|
115
|
-
@objc dynamic var profileText: String = ""
|
116
|
-
|
117
|
-
@objc dynamic var profileImage: Data? = nil
|
118
|
-
|
119
|
-
var tweets = List<Tweet>()
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
override static func primaryKey() -> String? {
|
124
|
-
|
125
|
-
return "id"
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
class Tweet: Object {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
@objc dynamic var tweetId: Int = 0
|
140
|
-
|
141
|
-
@objc dynamic var caption: String = ""
|
142
|
-
|
143
|
-
@objc dynamic var timestamp: Date!
|
144
|
-
|
145
|
-
@objc dynamic var retweetCount: Int = 0
|
146
|
-
|
147
|
-
@objc dynamic var likes: Int = 0
|
148
|
-
|
149
|
-
let users = LinkingObjects(fromType: User.self, property: "tweets")
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
override static func primaryKey() -> String? {
|
154
|
-
|
155
|
-
return "tweetId"
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
```
|