CollectDeviceData.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // CollectDeviceData.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/6/28.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import Foundation
  9. import ObjectMapper
  10. class CollectDeviceData:NSObject,NSCoding,Mappable{
  11. var unit:String?//上一步 选择的公司名称
  12. var mobile:String? //手机号码
  13. var code:String? //验证码
  14. var name:String?//设备号 友盟的token 中心服务器推送消息需要
  15. var deviceType:String? //设备类型 android ios
  16. struct CollectDeviceDataKey {
  17. static let unitKey = "unit"
  18. static let mobileKey = "mobile"
  19. static let codeKey = "code"
  20. static let nameKey = "name"
  21. static let deviceTypeKey = "deviceType"
  22. }
  23. override init(){
  24. }
  25. required init?(map: Map) {
  26. }
  27. func mapping(map: Map) {
  28. unit <- map["unit"]
  29. mobile <- map["mobile"]
  30. code <- map["code"]
  31. name <- map["name"]
  32. deviceType <- map["deviceType"]
  33. }
  34. init?(unit:String,mobile:String?,code:String?,name:String?,deviceType:String?){
  35. self.unit = unit
  36. self.mobile = mobile
  37. self.code = code
  38. self.name = name
  39. self.deviceType = deviceType
  40. }
  41. required convenience init?(coder aDecoder: NSCoder) {
  42. let unit = aDecoder.decodeObject(forKey: CollectDeviceDataKey.unitKey) as! String
  43. let mobile = aDecoder.decodeObject(forKey: CollectDeviceDataKey.mobileKey) as! String
  44. let code = aDecoder.decodeObject(forKey: CollectDeviceDataKey.codeKey) as! String
  45. let name = aDecoder.decodeObject(forKey: CollectDeviceDataKey.nameKey) as! String
  46. let deviceType = aDecoder.decodeObject(forKey: CollectDeviceDataKey.deviceTypeKey) as! String
  47. self.init(unit:unit,mobile: mobile,code: code,name: name,deviceType: deviceType)
  48. }
  49. func encode(with aCoder: NSCoder) {
  50. aCoder.encode(unit, forKey: CollectDeviceDataKey.unitKey)
  51. aCoder.encode(mobile, forKey: CollectDeviceDataKey.mobileKey)
  52. aCoder.encode(code, forKey: CollectDeviceDataKey.codeKey)
  53. aCoder.encode(name, forKey: CollectDeviceDataKey.nameKey)
  54. aCoder.encode(deviceType, forKey: CollectDeviceDataKey.deviceTypeKey)
  55. }
  56. }