Browse Questions
  • Timer and CADisplayLink cause memory leaks because the target-action API causes the active RunLoop to retain the timer, and the timer retains its target object until explicitly invalidated.
  • An iOS app moves through states managed by UIApplicationDelegate (UIKit) or @main + scene lifecycle (SwiftUI/iOS 13+).
  • Secure Session is Themis's stateful encrypted channel: peers perform a handshake, derive ephemeral session keys, and then exchange messages with forward secrecy over any transport you supply.
  • UITableView reuses cell objects as they scroll off screen rather than creating new ones, keeping memory usage constant regardless of how many rows exist.

Answer: UITableView reuses cell objects as they scroll off screen rather than creating new ones, keeping memory usage constant regardless of how many rows exist.

Code Example:

class MyViewController: UIViewController, UITableViewDataSource {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Register cell class with a reuse identifier
        tableView.register(UserCell.self, forCellReuseIdentifier: "UserCell")
    }

    func tableView(_ tableView: UITableView,
                   cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        // Dequeue a recycled cell (or create one if none available)
        let cell = tableView.dequeueReusableCell(
            withIdentifier: "UserCell", for: indexPath) as! UserCell

        // ALWAYS configure fully — recycled cells carry old data
        let user = users[indexPath.row]
        cell.nameLabel.text = user.name
        cell.avatarImageView.image = nil  // reset before async load

        return cell
    }
}

Common mistake: Not resetting cell state before configuring — old data shows briefly during scroll.