Ramotion / cardslider

:octocat: 🃏 Cardslider is a design UI controller that allows you to swipe through cards with pictures and accompanying descriptions.
https://www.ramotion.com/iphone-app-development-ui-library-for-swiping-through-objects/
MIT License
1.27k stars 102 forks source link

What is the Datasource object? #19

Closed Grauju closed 3 years ago

Grauju commented 4 years ago

Hi, im new to Xcode. And I'm asking me what the DataSource object is.

` guard let dataSource = test as? CardSliderDataSource else { return } let cardSlider = CardSliderViewController.with(dataSource: dataSource)

    cardSlider.title = "Movies"
    present(cardSlider, animated: true, completion: nil)

    `
igork-ramotion commented 3 years ago

This is just a protocol, you should implement it in your object and pass it to CardSliderViewController, so it will know what it should display.

public protocol CardSliderDataSource: class {
    /// CardSliderItem for the card at given index, counting from the top.
    func item(for index: Int) -> CardSliderItem

    /// Total number of cards.
    func numberOfItems() -> Int
}

Please take a look at example project for mo details