When creating a label that uses data from an API within a closure that returns data from that api:
APIData().getRequest(epicGamesUsername: "test") { (output) in
DispatchQueue.main.async {
let winsLabelForProfile = Label().createLabel(labelText: output[0], font: "Avenir-HeavyOblique", fontSize: 45, center: center, centerX: centerX, centerY: centerY, offsetX: 0, offsetY: -(self.view.frame.width / 13), height: self.view.frame.width / 6, width: self.view.frame.width / 2, textAlignment: NSTextAlignment.center)
self.view.addSubview(winsLabelForProfile)
}
I have to put the creation of the label back onto the main thread.
My question is simply: is adding the label this way going to slow my app down? If so, what is a better way to accomplish this?
When I test adding a label without adding it asynchronously, it definitely seems faster.