mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
27 lines
770 B
Swift
27 lines
770 B
Swift
//
|
|
// AlbumDataSource.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2019/2/20.
|
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class AlbumDataSource: NSObject, UICollectionViewDataSource {
|
|
var albums: [Album] = []
|
|
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
return albums.count
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
let item = collectionView.dequeueReusableCell(withReuseIdentifier: "AlbumViewCell", for: indexPath)
|
|
guard let albumViewCell = item as? AlbumItemCell else { return item }
|
|
|
|
albumViewCell.setAlbum(albums[indexPath.item])
|
|
|
|
return albumViewCell
|
|
}
|
|
}
|