如何将类型 'MoviesDataSource.Section.Item' 的值转换为闭包结果类型 'Movie'
how convert value of type 'MoviesDataSource.Section.Item' to closure result type 'Movie'
我有 2 个对象,一个是电影,一个是部分我有这个错误消息“无法将类型 'MoviesDataSource.Section.Item' 的值转换为闭包结果类型 'Movie'”有人可以帮我解决这个问题吗?
struct Section {
struct Item {
let identifier: Int
let title: String
let thumbnailURL: URL
}
let items: [Movie]
}
/// The sections that comprise the data source.
let sections: [Section]
/// Describes the ways that items can be distributed across sections.
enum SectionStyle {
case single
case byAGenres(maximumItemsPerAlbum: Int?, maximumNumberOfAlbums: Int?)
}
init(movies: [Movie], sectionStyle: SectionStyle) {
switch sectionStyle {
case .single:
self.sections = [Section(items: movies.map { Section.Item(identifier: [=12=].id, title: [=12=].title, thumbnailURL: [=12=].posterURL)})]< "Cannot convert value of type 'MoviesDataSource.Section.Item' to closure result type 'Movie'"
打字错误。
替换
let items: [Movie]
和
let items: [Item]
我有 2 个对象,一个是电影,一个是部分我有这个错误消息“无法将类型 'MoviesDataSource.Section.Item' 的值转换为闭包结果类型 'Movie'”有人可以帮我解决这个问题吗?
struct Section {
struct Item {
let identifier: Int
let title: String
let thumbnailURL: URL
}
let items: [Movie]
}
/// The sections that comprise the data source.
let sections: [Section]
/// Describes the ways that items can be distributed across sections.
enum SectionStyle {
case single
case byAGenres(maximumItemsPerAlbum: Int?, maximumNumberOfAlbums: Int?)
}
init(movies: [Movie], sectionStyle: SectionStyle) {
switch sectionStyle {
case .single:
self.sections = [Section(items: movies.map { Section.Item(identifier: [=12=].id, title: [=12=].title, thumbnailURL: [=12=].posterURL)})]< "Cannot convert value of type 'MoviesDataSource.Section.Item' to closure result type 'Movie'"
打字错误。
替换
let items: [Movie]
和
let items: [Item]