U
U
uzolenta2019-06-07 14:18:14
Swift
uzolenta, 2019-06-07 14:18:14

How to hide/show an element before the functions start executing?

How to hide/show an element before the functions start executing?

@IBAction func changeButton(_ sender: Any) {

table.isHidden = true
            func1()
            func2()
    }

table.IsHidden = true Executed only after two functions have been executed. How to make it so that the element is hidden at the beginning, and then the functions are already executed? In the function of working with the network.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
uzolenta, 2019-06-07
@uzolenta

DECISION:

@IBAction func changeButton(_ sender: Any) {
        DispatchQueue.global().async {
DispatchQueue.main.async(){
        self.table.isHidden = true
        self.activityIndicator.startAnimating()
    }

/*Внутри функций работа с сетью, sqlite базой, много циклов*/
            self.func1()
            self.func2()
            
            DispatchQueue.main.async(){
                self.readLovers() - тут подгрузка данных для table, соот., и table.reloadData()
                self.activityIndicator.stopAnimating()
                self.table.isHidden = false
            }
        
        }
    }

I
Ivan Vorobei, 2019-06-07
@ivanvorobei

The code you provided works consistently.
For example code:

override func viewDidLoad() {
    super.viewDidLoad()
    self.tableView.isHidden = true
    print("table is hidden: \(tableView.isHidden)")
    self.do1()
    self.do2()
}
    
func do1() {
   print("do 1")
}
    
func do2() {
   print("do 2")
}

Will output to the console:
table is hidden: true
do 1
do 2

Just wrote a project.
The problem is not in the order of execution of the functions - it is sequential. More information needed to help.
UPD: Author boor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question