/
TweetsTableViewCell.swift
executable file
·113 lines (60 loc) · 2.59 KB
/
TweetsTableViewCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// TweetsTableViewCell.swift
// Twitter
//
// Created by user on 2/18/16.
// Copyright © 2016 Aurielle. All rights reserved.
//
import UIKit
class TweetsTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
profileImageView.layer.cornerRadius = 5
profileImageView.clipsToBounds = true
userNameLabel.preferredMaxLayoutWidth = userNameLabel.frame.size.width
// Initialization code
}
@IBOutlet weak var userNameLabel: UILabel!
@IBOutlet weak var timeCreatedLabel: UILabel!
@IBOutlet weak var profileImageView: UIImageView!
@IBOutlet weak var tweetContent: UILabel!
@IBOutlet weak var authorLabel: UILabel!
@IBOutlet weak var favButton: UIButton!
@IBOutlet weak var retweetButton: UIButton!
@IBOutlet weak var retweetCountLabel: UILabel!
@IBOutlet weak var favCountLabel: UILabel!
class Tweet: NSObject {
var user: User?
var author: String?
var text: String?
var createdAtString: String?
var createdAt: NSDate?
var id: String
var favTotal: Int?
var retweetTotal: Int?
var tweetID: String = ""
init(dictionary: NSDictionary) {
text = dictionary["text"] as? String
createdAtString = dictionary["created_at"] as? String
let formatter = NSDateFormatter()
formatter.dateFormat = "EEE MMM d HH:mm:ss Z y"
createdAt = formatter.dateFromString(createdAtString!)
user = User(dictionary: dictionary["user"] as! NSDictionary )
author = dictionary["author"] as? String
favTotal = dictionary["favorite_count"] as? Int
retweetTotal = dictionary ["retweet_count"] as? Int
id = String(dictionary["id"]!)
}
class func tweetWithArray(array: [NSDictionary]) -> [Tweet] {
var tweets = [Tweet]()
for dictionary in array {
print(dictionary)
tweets.append(Tweet(dictionary: dictionary))
}
return tweets
}
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}