Reputation: 1133
I am currently working on a project that uses a company's API and populate my tableView with those data. However, my program works by having the user to search for the information through in game names and then the data will be displayed after a click on the "search" button
The problem I am facing with is that my 3 tableView functions
numberOfSectionsInTableView(tableView: UITableView) -> Int
tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
all loads when the app loads instead of AFTER the user's call to pull the information through the API
I was thinking if swift can do a function within a function but Xcode gives me an error of does not conform to protocol error
Is there anyway I can make the tableView load AFTER my user's have clicked the search button?
Thanks!
Upvotes: 2
Views: 1137
Reputation: 1192
After you have guaranteed that you have the data run the method
tableView.reloadData()
This will refresh the table view and load any new data in it.
Upvotes: 2