Last active
October 28, 2017 01:50
-
-
Save dnaismyth/3b14b1d7cea1ad71b8a403a1324bc746 to your computer and use it in GitHub Desktop.
Comment for nintendo tutorial
This file contains 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 | |
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