-1

I have a container view which covers the entire initial view controller with a label in the top right corner of the same view i.e. on top of the container view. I need to change the text of a label at times from views inside the container view. The label basically contains the score of the quiz and needs to be updated as the user gets a correct answer. The label is on top of the container view so that it is seen on all views inside the container view at exact same position. Please help as I am new to swift.

user3789185
  • 71
  • 1
  • 9

1 Answers1

1

You can use NSNotificationCenter to update the scores in container view. You can do this in following way:

  1. make your views fire a notification everytime the score changes.

  2. Make you container view(containing the label) listen to those notifications and then change the label text accordingly.

You can refer to this link on how to use NSNotificationCenter : https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/

manish_kumar
  • 260
  • 2
  • 12