0

I'm using this library https://github.com/Yalantis/Koloda Basically this is a pod that helps me implement a Tinder-like swiping interface.

This pod has a Data Source method called kolodaNumberOfCards(_ koloda: KolodaView) which requires you to declare how many cards the program is expecting to show in the Koloda View.

func kolodaNumberOfCards(_ koloda: KolodaView) -> Int {
        return allCards.list.count
}

I am implementing a MVC architecture in my app so I have a Data Model class file which I instantiate at the top of this current view controller.

var allCards = QuestionBank()

In QuestionBank class, I have a list (array) of Card objects which contains all the metadata of the Card objects. Card object also contains the UIImage I want to instantiate in the KolodaCard View.

PROBLEM COMES when I do not have the Card objects in the QuestionBank list array at init! These Card objects are appended to the list after I fetch data remotely from an API.

However, in my ViewController containing the KolodaView, I need to declare how many cards the program is expecting to show in the Koloda View. Since list.count is 0 when you first enter the ViewController, the KolodaView would thus expect 0 card!

Currently my KolodaView is not showing any of my downloaded images.

Is there a way to delay the Data Source methods by Koloda so that the program can wait for all the data to be fetched from API or is there another solution around this problem?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Seng Wee
  • 534
  • 9
  • 20
  • No need to delay. After you get the remote data and update your data model, call whatever API the view provides to reload it (similar to `UITableView reloadData`. – rmaddy Jun 11 '18 at 03:24
  • what about the kolodaNumberOfCards part where I need to declare how many cards are there but at the start there is no element in the list so the program assume there is going to be 0 card in the Koloda View? – Seng Wee Jun 11 '18 at 04:08
  • Let it start out at 0. Once the data is updated and you reload the data, it will return the updated number. – rmaddy Jun 11 '18 at 04:46

0 Answers0