import Foundation struct CommentsModel { var comment = "" var gameId = "" var timestamp = 0 var userId = "" var userModel = UserModel(user: [:]) init(comment: [String: Any]) { self.comment = comment["comment"] as? String ?? "" self.gameId = comment["gameId"] as? String ?? "" self.timestamp = comment["timestamp"] as? Int ?? 0 self.userId = comment["userId"] as? String ?? "" if let userDict = comment["userModel"] as? [String: Any] { self.userModel = UserModel(user: userDict) } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter