There is a class with two variables for defining an array
import Foundation class AddClass: NSObject, NSCoding{ var name500: String var date500: String init(name500:String, date500:String) { self.name500 = name500 self.date500 = date500 } func encode(with aCoder: NSCoder) { aCoder.encode(name500, forKey: "name500") aCoder.encode(date500, forKey: "date500") } required init?(coder aDecoder: NSCoder) { self.name500 = aDecoder.decodeObject (forKey: "name500") as! String self.date500 = aDecoder.decodeObject (forKey: "date500") as! String } } There are two arrays defined by the class in which to write data from ordinary arrays of type String
var names: [AddClass] = [] var dates: [AddClass] = [] These two arrays of type String get the values from the parsing and look like this:
nameGame500 = ((url.object(forKey: "links") as! NSArray).value(forKeyPath: "name") as! NSArray) as! [String] dategame500 = ((url.object(forKey: "links") as! NSArray).value(forKeyPath: "release_date") as! NSArray) as! [String] Need to do what would
var names: [AddClass] = [] был равен nameGame500 var dates: [AddClass] = [] был равен dategame500 This method works only if there is one variable in the class.
names = nameGame500.map({ AddClass(name500: $0) }) but if two
names = nameGame500.map({ AddClass(name500: $0) }) dates = dategame500.map({ AddClass(date500: $0) }) it gives an error
'map' produces '[T]', not the expected contextual result type '[AddClass]' UPD:
let ss = names.map {names -> [Image] in let arrayImage = names.images let sv = arrayImage.filter {arrayImage -> Bool in let typeUrl = arrayImage.type return typeUrl == 1 } return sv }