0
@IBOutlet private weak var tableView: UITableView!
@IBAction private func backButton(_ sender: UIBarButtonItem){
    navigationController?.popViewController(animated: true)
}

Do you think it's right to put private on outlets and actions as above? I've never seen a coding style like this before. However, in the access controller, if you use it only in inner classes, you should use Private. I'm trying to reduce memory by using private, is this the right way to do it?

ga-yo
  • 123
  • 1
  • 2
  • 11
  • 1
    Unrelated to your question; don't declare outlets as weak variables unless you need to avoid a retain cycle. More info [here](https://stackoverflow.com/questions/7678469/should-iboutlets-be-strong-or-weak-under-arc) – Desdenova Jul 26 '21 at 13:22

1 Answers1

2

Making a variable private does not reduce your memory footprint, just who has access to the variable.

I make my IBOutlets private because they are instantiated by the Storyboard or the nib and I'd rather not have any other parts of the app interact with them.

Abizern
  • 146,289
  • 39
  • 203
  • 257