0

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,

B.Ticca
  • 23
  • 5
  • Possible duplicate of [Passing Data between View Controllers](https://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – Tamás Sengel Feb 01 '18 at 12:41

1 Answers1

1

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

Artyom Vlasenko
  • 385
  • 3
  • 16