Skip to content

Instantly share code, notes, and snippets.

@dnaismyth
Last active October 28, 2017 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnaismyth/3b14b1d7cea1ad71b8a403a1324bc746 to your computer and use it in GitHub Desktop.
Save dnaismyth/3b14b1d7cea1ad71b8a403a1324bc746 to your computer and use it in GitHub Desktop.
Comment for nintendo tutorial
import Foundation
class Comment {
var id: Int?
var game: Game?
var author: String?
var text: String?
var createdDate: String?
init(){}
init(data: [String: AnyObject]){
id = data["id"] as? Int
author = data["author"] as? String
text = data["text"] as? String
createdDate = data["createdDate"] as? String
if let gameData = data["game"] as? [String: AnyObject] {
game = Game(data: gameData)
}
}
// Use to map Comment object into dictionary - this will be used to POST to the server.
// We do not have to worry about setting our Game object nor our createdDate as we handle this on the server side.
func convertToDictionary() -> [String: AnyObject] {
var dict = [String: AnyObject]();
dict["id"] = self.id as AnyObject
dict["author"] = self.author as AnyObject
dict["text"] = self.text as AnyObject
return dict
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment