I'm trying to cast/ convert a custom object to string but keep getting the error:
Cannot invoke initializer for type 'String' with an argument list of type '(ArtInfo)'
I have a custom class:
class ArtInfo {
var poster: String?
var artwork: String?
var fanart: String?
init (poster: String?, artwork: String?, fanart: String?){
self.poster = poster
self.artwork = artwork
self.fanart = fanart
}
}
After retrieving the values (json data) I'm trying to put them in local arrays. The arrays are split up by category, the json retrieval and parsing covers all the data not just this particular class. Here is how I append the data to the local array:
var photosArray: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
DetailShowInfo.updateAllDetails(urlExtension: url, completionHandler: { details in
let artPics = ArtInfo.init(poster: details[0].poster, artwork: details[0].artwork, fanart: details[0].fanart)
self.photosArray.append(String(artPics))// Error happens here
})
}
String(artPics)supposed to do? - luk2302