Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import Foundation
  2. import ObjectMapper
  3.  
  4. class LocationModel: Mappable{
  5. init(latitude: Double = 0.0,longitude: Double = 0.0,timestamp:NSDate = NSDate()){
  6. self._latitude = latitude
  7. self._longitude = longitude
  8. self._timestamp = timestamp
  9. }
  10.  
  11. required init?(_ map: Map) {
  12. }
  13.  
  14. func mapping(map: Map) {
  15. if map.mappingType == .ToJSON{
  16. self._latitude <- map["latitude"]
  17. self._longitude <- map["longitude"]
  18. self._timestamp <- map["timestamp"]
  19. }
  20. }
  21.  
  22. var _latitude: Double?
  23. var _longitude: Double?
  24. var _timestamp: NSDate?
  25. }
  26. var location = LocationModel(42.9837, -81.2497,NSDate())
  27. let JSONString = Mapper().toJSON(npForm)
  28. print(JSONString)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement