title: Swift : EXC_BAD_ACCESS
body: <p>I ran into the error code that haunts any Apple developer today <code>EXC_BAD_ACCESS</code> .. After ample amounts of research, on different ways to debug etc I have landed here.</p>
  
  <p>UPDATE : Here is the link to the GitHub repo if anyones willing to help solve this problem <a href="https://github.com/TheRiseCollection/sway" rel="nofollow noreferrer">https://github.com/TheRiseCollection/sway</a></p>
  
  <p>Turning on <code>zombie objects</code> in Xcode showed me that the <code>nil</code> here <code>guard let view = nib.instantiate(withOwner: self, options: nil).first as? T</code> is causing my problem <code>Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeec121e98)</code></p>
  
  <p>Here is a look at the full file NibView.swift</p>
  
  <pre><code>//Joshua Paulsen - The Rise Collection
  
  
  
  import UIKit
  
  /// A base UIView subclass that instaniates a view
  /// from a nib file of the same class name in order to
  /// allow reusable views to be created.
  internal protocol NibView where Self: UIView {
  
  }
  
  extension NibView {
  
      /// Initializes the view from a xib
      /// file and configure initial constrains.
      func xibSetup() {
          backgroundColor = .clear
          let view = loadViewFromNib()
          addEdgeConstrainedSubView(view: view)
      }
  
      /// Loads a view from it's xib file.
      ///
      /// - Returns: an instantiated view from the Nib file of the same class name.
      fileprivate func loadViewFromNib&lt;T: UIView&gt;() -&gt; T {
          let bundle = Bundle(for: type(of: self))
          let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
          guard let view = nib.instantiate(withOwner: self, options: nil).first as? T else {
              fatalError("Cannot instantiate a UIView from the nib for class \(type(of: self))")
          }
          return view
      }
  
  }
  </code></pre>
  
  <p>I'm new to messing around with nib views! Looking for a fix here any help is appreciated.</p>