How to make the prepareForWhy wait for a certain processing to finish to be called?

Asked

Viewed 58 times

0

By clicking a certain button I make a query in firebase to return data, however this same button calls another view controller, and the problem is there, the view controller is called before the firebase returns all data, and consequently values are passed as nil. I was thinking about thread management (pause a thread) or something like that, but I don’t know if that’s it. Is there any way I can run the prepareForSerge only after the end of a certain processing ?

  • It would be more interesting to 'schedule' in the iOS process queue, inside the viewcontroller already called this execution should be in the onDidLoad(). Put the code you already have in question. Which version of Swift uses?

1 answer

1


You can do the following:

  • Remove existing Follows that was created from the button
  • Create a new one by dragging the yellow icon from the source controller to the target controller
  • Click on the following created and give an Identifier to it by the Attributes Inspector tab, for example ExibeDados
  • After returning Firebase data, run the following code:
performSegue(withIdentifier: "ExibeDados", sender: nil)

That way the following is not called automatically when you click the button and you can call it when you want.

  • 1

    I did what you told me and it worked, simple to solve. Thank you very much !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.