×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Nigel Smith
Added: Sep 16, 2017 5:14 PM
Views: 1
  1.     let encoder = JSONEncoder()
  2.     let decoder = JSONDecoder()
  3.     for figure in figures
  4.     {
  5.         if let encoded = try? encoder.encode(figure)
  6.         {
  7.             if let encoded = try? decoder.decode(MythicalFigure.self, from: encoded)
  8.             {
  9.                 figuresDeepCopy.append(encoded)
  10.             }
  11.         }
  12.     }