Neal Sanche
02/03/2021, 12:34 AMsuspend fun getEpisodes(page: Int?): EpisodePage
On the Swift side, have been try to write code but always am told:
Cannot convert value of type 'Int32' to expected argument type 'KotlinInt?'
This confuses me, and I'm sure there's a simple explanation. I can change the function signature to getEpisodes(page: Int = 1)
instead, and that's much easier to deal with. So I'm curious what's going on here?Neal Sanche
02/03/2021, 12:40 AMBarco
02/03/2021, 12:41 AMBarco
02/03/2021, 12:41 AMBarco
02/03/2021, 12:41 AMNeal Sanche
02/03/2021, 12:49 AMBarco
02/03/2021, 12:54 AMNeal Sanche
02/03/2021, 12:57 AMCould not cast value of type '__NSCFNumber' (0x7fff86d65440) to 'SharedInt' (0x10df11200).
Neal Sanche
02/03/2021, 1:01 AMNeal Sanche
02/03/2021, 1:05 AMclass EpisodeViewModel: ObservableObject {
@Published public var episodes: [Episode] = []
let repository = TestRepository()
var nextPage: NSNumber? = nil
func fetchEpisodes() {
repository.getEpisodes(page: (self.nextPage as? KotlinInt)) { (data, error) in
if let newEpisodes = data?.episodes {
self.episodes.append(contentsOf: newEpisodes)
}
self.nextPage = data?.nextPage
}
}
public var shouldDisplayNextPage: Bool {
return nextPage != nil
}
}
Barco
02/03/2021, 1:05 AMKotlinInt(self.nextPage!)
Neal Sanche
02/03/2021, 1:06 AMBarco
02/03/2021, 1:12 AM