func computeMonteCarlo(iterations: Int) {
DispatchQueue.concurrentPerform(iterations: iterations) { _ in
// Here's were the calculation happens. Omitted for brevity.
DispatchQueue.main.async {
self.monteCarloGraph.addSubview(point)
// Lines that need to be updated.
let pi = 4.0 * Double(self.nPointsInside) / Double(self.nIterations)
self.piLabel.text = String(pi)
}
}
}