title: Change the UILabel when a static variable changes
body: <p>I have a <code>CartItem</code> struct where I store the items that I show in a <code>UITableView</code> My <code>UITableView</code> is in <code>CartViewController</code>. I use <code>custom cell</code> for my <code>table view</code>. Here is my <code>custom cell</code>:</p>
  <pre><code>class CartItemCell: UITableViewCell {
  
  @IBOutlet weak var productImage: UIImageView!
  @IBOutlet weak var productName: UILabel!
  @IBOutlet weak var productPrice: UILabel!
  @IBOutlet weak var productTotalPrice: UILabel!
  @IBOutlet weak var stepper: UIStepper!
  
  
  
  override func awakeFromNib() {
      super.awakeFromNib()
      // Initialization code
  }
  
  var cellIndex: Int?
  
  var product: CartItem?{
      didSet{
      
      // change the cell in table view when first 
      // initialized and when stepper value is changed 
      .
      .
      .
  }
  
  @IBAction func stepperValueChanged(_ sender: UIStepper) {
      CartItem.cartItems[self.cellIndex!].number = Int(sender.value)
      self.product?.number = CartItem.cartItems[self.cellIndex!].number
      }
  }
  </code></pre>
  <hr />
  <p>In <code>CartViewController</code> I have <code>totalPrice UILabel</code> which gets its value from <code>CartItem.totalPrice</code> static variable. <code>CartItem.totalPrice</code>'s value is calculated and changed every time <code>UIStepper</code> in my <code>UITableViewCell</code> is clicked. Here is the summary of  <code>CartViewController</code></p>
  <pre><code>class CartViewController: UIViewController{
  
  @IBOutlet weak var tableView: UITableView!
  @IBOutlet weak var cartLabel: UILabel!
  @IBOutlet weak var totalPrice: UILabel!
  
  var items = CartItem.cartItems
  
  override func viewDidLoad() {
      super.viewDidLoad()
      tableView.dataSource = self
      tableView.delegate = self
      tableView.register(UINib(nibName: &quot;CartItemCell&quot;, bundle: nil), forCellReuseIdentifier: &quot;ReusableCell&quot;)
      self.totalPrice.text = String(Int(CartItem.totalPrice))
      tableView.reloadData()
  }
  }
  
  
  extension CartViewController: UITableViewDataSource{
  
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return items.count
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: &quot;ReusableCell&quot;, for: indexPath) as! CartItemCell
      
      cell.product = items[indexPath.item]
      cell.cellIndex = indexPath.item
      return cell
  }
  
  }
  </code></pre>
  <hr />
  <hr />
  <hr />
  <h1>I want <code>totalPrice</code> label in the <code>CartViewController</code> changed every time <code>CartItem.totalPrice</code> is changed. I change the value of the <code>CartItem.totalPrice</code> in my <code>CartItemCell</code></h1>
  <hr />
  <hr />
  <h2>Thank you</h2>