Created
August 6, 2016 04:53
-
-
Save niwatako/167a6cdaad0a2690b424c47a085e8408 to your computer and use it in GitHub Desktop.
Tweet.swiftはいまこうなってるはず #CodePiece #realm_swift #realm_jp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import RealmSwift | |
class Tweet: Object { | |
dynamic var name = "" | |
dynamic var text = "" | |
dynamic var iconURL = "" | |
dynamic var id = "" | |
dynamic var createdAt = NSDate() | |
static var dateFormatter: NSDateFormatter { | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") | |
dateFormatter.dateFormat = "EEE MMM dd HH:mm:ss Z yyyy" | |
return dateFormatter | |
} | |
convenience init(tweetDictionary: [String: AnyObject]) { | |
self.init() | |
let user = tweetDictionary["user"] as! [String: AnyObject] | |
name = user["name"] as! String | |
text = tweetDictionary["text"] as! String | |
iconURL = user["profile_image_url_https"] as! String | |
id = tweetDictionary["id_str"] as! String | |
createdAt = Tweet.dateFormatter.dateFromString(tweetDictionary["created_at"] as! String)! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment