Blame view

App/model/ShootItem.swift 861 Bytes
defd9642e   Trịnh Văn Quân   version 1.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  import Foundation
  import GeneralUtils
  
  class ShootItem: Equatable, Mappable {
      var id: Int?
      var name: String?
      var willShoot: Int?
      var signboard: Int?
      var imgs: [ImgObj]?
  
      init(id: Int? = nil, name: String? = nil) {
          self.id = id
          self.name = name
      }
  
      func addImg(img: ImgObj) {
          if imgs == nil { imgs = [ImgObj]() }
          imgs?.append(img)
      }
  
      // region: ========== Mappable
      init() {}
      required init?(map: Map) {}
  
      func mapping(map: Map) {
          id <- map["id"]
          name <- map["name"]
          willShoot <- map["willShoot"]
          imgs <- map["imgs"]
      }
      //endregion
  }
  
  func ==(lhs: ShootItem, rhs: ShootItem) -> Bool {
      if let lhsName = lhs.name, let rhsName = rhs.name {
          return lhsName == rhsName
      }
      return ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
  }