I have a project that I'm using Argo and I'm getting the error mentioned in title.
The error is in the line
<*> json <||? ["info", "images", "poster_original"]
Honestly I cannot understand what's wrong, this project was in swift 2 something and this happened when migrating to swift 3.
My dependencies are (in case you may think there's some sort of conflict):
pod 'Alamofire', '~> 4.2'
pod 'Kingfisher', '~> 3.2'
pod 'Argo', '~> 4.1'
pod 'Curry', '~> 3.0'
pod 'SwiftyUserDefaults', '~> 3.0'
Here's my class:
class Movie: Decodable {
public static func decode(_ json: JSON) -> Decoded<Movie> {
let a = curry(Movie.init)
<^> json <| "title"
<*> json <||? ["info", "rating", "imdb"]
<*> json <||? ["info", "images", "poster"]
<*> json <|? ["info", "imdb"]
<*> json <|? ["info", "plot"]
let b = a
<*> json <| ["info", "year"]
<*> json <|? ["info", "runtime"]
<*> json <|? ["info", "tagline"]
<*> json <|? ["info", "mpaa"]
<*> json <|| ["info", "genres"]
let c = b
<*> json <||? ["info", "images", "poster_original"]
<*> json <||? ["info", "images", "backdrop"]
<*> json <||? ["info", "images", "backdrop_original"]
<*> .optional(json <| ["info", "images", "actors"] >>- { [String: String].decode($0) })
<*> json <|? "status"
<*> json <|? ["info", "in_wanted", "status"] <|> pure(nil)
if let error = c.error {
NSLog("### ERROR DECODING DISCOVERY MOVIE --> \(error.description)")
}
return c
}
let name: String
let rating: [Float]?
let postersUrls: [String]?
let imdbId: String?
let plot: String?
let year: Int
let length: Int?
let tagline: String?
let mpaa: String?
let genres: [String]
let postersOriginalUrls: [String]?
let backdropsUrls: [String]?
let backdropsOriginalUrls: [String]?
let actorsWithPictures: [String: String]?
let libraryStatus: String?
let wantedStatus: String?
var status: MovieStatus
var mainPosterUrl: String? {
if let urls = postersOriginalUrls, urls.count > 0 {
return urls.first
}
if let urls = postersUrls, urls.count > 0 {
return urls.first
}
return nil
}
init(name: String,
rating: [Float]?,
postersUrls: [String]?,
imdbId: String?,
plot: String?,
year: Int,
length: Int?,
tagline: String?,
mpaa: String?,
genres: [String],
postersOriginalUrls: [String]?,
backdropsUrls: [String]?,
backdropsOriginalUrls: [String]?,
actors: [String: String]?,
libraryStatus: String?,
wantedStatus: String?) {
self.name = name
self.rating = rating
self.postersUrls = postersUrls
self.imdbId = imdbId
self.plot = plot
self.year = year
self.length = length
self.tagline = tagline
self.mpaa = mpaa
self.genres = genres
self.postersOriginalUrls = postersOriginalUrls
self.backdropsUrls = backdropsUrls
self.backdropsOriginalUrls = backdropsOriginalUrls
self.actorsWithPictures = actors
self.libraryStatus = libraryStatus
self.wantedStatus = wantedStatus
self.status = MovieStatus.statusFromLibraryStatus(ls: libraryStatus, andWantedStatus: wantedStatus)
}
}
UPDATE:
I created an MCVE, you can download it from https://drive.google.com/open?id=0B35AMbs00yEQWHc2M2s1bDdDdVk , just open the xcworkspace and try to compile it.