Browse Questions
  • OSLog is Apple's structured logging framework.
  • Firebase Cloud Messaging (FCM) lets you send push notifications to your iOS app through Apple Push Notification service (APNs).
  • URLCache stores responses from network requests in memory and/or on disk.
  • 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.