title: Xcode 9: Getting More Information On Memory Leak
body: <p>After learning that a memory leak may be the cause of my iOS app crashing hours after being installed onto my phone, I've watched and read videos/articles surrounding memory leaks, specifically in Xcode and how to debug them. I've been trying to use the Memory Debugger and Xcode leaks instrument with no luck. I am wondering, how do I find the source of my leaks? The screenshot I attached shows one of the many leaks and it never lets me dig deeper than what the picture shows. In videos, Xcode takes them to the line of code causing the issue using the backtrace, however I have not been able to do that in any of the cases. I am also noticing the leaks are coming from the UIKIT, is this normal? Appreciate any help as I am fairly new to Xcode.</p>
  
  <p><a href="https://i.stack.imgur.com/an2hC.png" rel="nofollow noreferrer">Here is the image.</a></p>
  
  <p>Here is some code from my initial log in view controller. In the second image you'll see that the only view that has a memory leak is this one, however - I can't dig deeper on this either. 
  <a href="https://i.stack.imgur.com/lKciv.png" rel="nofollow noreferrer">Second image of memory leak from InitialLogInVC</a></p>
  
  <pre><code>import UIKit
  
  class IntialLoginInViewController: UIViewController {
      @IBOutlet weak var backgroundAlbumArt: UIImageView!
      @IBOutlet weak var foregroundAlbumArt: UIImageView!
      @IBOutlet weak var musicNameLabel: UILabel!
      private weak var imageOne = UIImage(named: "taste.jpg")
      private weak var imageTwo = UIImage(named: "NavReckless.jpg")
      private weak var imageThree = UIImage(named: "watch.jpg")
      private weak var imageFour = UIImage(named: "juicewrld.jpg")
  
      lazy var imageInformation = [(name:"Taste - Tyga", image:imageOne),(name:"Reckless - Nav", image: imageTwo),(name:"Watch - Travis Scott", image: imageThree), (name:"Goodbye &amp; Good Riddance - Juice Wrld", image: imageFour)]
      private var currentIndex = 0
      static var spotifySession: AnyObject?
  
      override func viewDidLoad() {
          super.viewDidLoad()
          foregroundAlbumArt.image = imageOne
          backgroundAlbumArt.image = imageOne
          musicNameLabel.text = imageInformation[0].name
          let _ = Timer.scheduledTimer(timeInterval: 10.0, target: self, selector: #selector(imageRefresh), userInfo: nil, repeats: true)
      }
  
      override var preferredStatusBarStyle : UIStatusBarStyle {
          return .lightContent
      }
  
      @objc func imageRefresh(){
          if currentIndex == imageInformation.count - 1 {
              currentIndex = 0
          }
          else {
              currentIndex += 1
          }
          //Update Label
          UIView.transition(with: self.musicNameLabel, duration: 2.0, options: [.transitionCrossDissolve] , animations: {
              self.musicNameLabel.text = self.imageInformation[self.currentIndex].name
  
          }, completion: nil)
          //Update foreground Album
          UIView.transition(with: self.foregroundAlbumArt, duration: 2.0, options: [.transitionCrossDissolve] , animations: {
              self.foregroundAlbumArt.image = self.imageInformation[self.currentIndex].image
          }, completion: nil)
          //Update background Album
  
          UIView.transition(with: self.backgroundAlbumArt, duration: 2.0, options: [.transitionCrossDissolve] , animations: {
              self.backgroundAlbumArt.image = self.imageInformation[self.currentIndex].image
          }, completion: nil)
  
      }
  
  }
  </code></pre>