B.Ticca
B.Ticca

Reputation: 23

How can I change label text from another viewController/Class?

I have a label that shows the amount of gold in ViewController1. If the user makes a purchase in the in-game-store in ViewController2, how can I update the labels text in ViewController1?

Basically, how can i change the label text from anoter viewController? Thanks,

Upvotes: 0

Views: 161

Answers (1)

Artyom Vlasenko
Artyom Vlasenko

Reputation: 385

In vc2 create closure something like this

var actionBuy:(()->())?

when action tapped use this actionBuy?()

it called in vc1

vc2.actionBuy = { label.text = "action is done" }.

good luck

Upvotes: 1

Related Questions