Anonymous Anonymous - 16 days ago
148 0

No description

Swift

example_loop

func encode(to encoder: Encoder) throws { 
   var container = encoder.container(keyedBy: CodingKeys.self)

   var arrs = [AnyClass]()

   for stype in [A, B] {
      arrs.append([stype]())
   }

  for event in self.events {
      if event is A {
         listOfA.append(event as! A)
      } 
      if event is B {
         listOfB.append(event as! B)}
      }
   
   for  arr in arrs {
      try encoder.encode(arr, forKey: //some arbitrary key)
   }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download