title: Cannot Find In Scope Despite Variable Declared In Class
body: <p>I am programming a basic fps app on Xcode using Swift. The error comes in my Bitmap.swift file, which is meant to store pixels in a 2D array so that there's a way to represent an entire image in the app.</p>
  <p>The code goes as follows:</p>
  <pre><code>import UIKit
  
  class Bitmap: UIViewController {
  
      public struct Bitmap
      {
          public private(set) var pixels: [Color]
          public let width: Int
          
          public init(width: Int, pixels: [Color])
          {
              self.width = width
              self.pixels = pixels
          }
      }
      
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
      }
      
  
      /*
      // MARK: - Navigation
  
      // In a storyboard-based application, you will often want to do a little preparation before navigation
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          // Get the new view controller using segue.destination.
          // Pass the selected object to the new view controller.
      }
      */
  
  }
  
  
  extension Bitmap
  {
      var height: Int
      {
          return pixels.count / width
      }
      subscript(x: Int, y: Int) -&gt; Color
      {
          get { return pixels[y * width + x] }
          set { pixels[y * width + x] = newValue}
      }
      convenience init(width: Int, height: Int, color: Color) {
          self.pixels = Array(repeating: color, count: width * height)
          self.width = width
      }
  }
  </code></pre>
  <p>Despite having &quot;pixels&quot; and &quot;width&quot; declared in my class I keep getting these errors for my extension function:</p>
  <p>&quot;Cannot find 'pixels' in scope&quot;
  &quot;Cannot find 'width' in scope&quot;
  &quot;Value of type 'Bitmap' has no member 'pixels'&quot;
  &quot;Value of type 'Bitmap' has no member 'width'&quot;</p>
  <p>Edit: Here is the code for my other file &quot;Color.swift&quot;</p>
  <pre><code>import UIKit
  
  class Color: UIViewController {
      
      public struct Color {
          public var r, g, b, a: UInt8
          
          public init(r: UInt8, g: UInt8, b: UInt8, a: UInt8 = 255)
          {
              self.r = r
              self.g = g
              self.b = b
              self.a = a
          }
      }
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
      }
      
  
      /*
      // MARK: - Navigation
  
      // In a storyboard-based application, you will often want to do a little preparation before navigation
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          // Get the new view controller using segue.destination.
          // Pass the selected object to the new view controller.
      }
      */
  
  }
  
  
  extension Color {
      static let clear = Color(r: 0, g: 0, b: 0, a: 0)
      static let black = Color(r: 0, g: 0, b: 0)
      static let white = Color(r: 255, g: 255, b: 255)
      static let gray = Color(r: 192, g: 192, b: 192)
      static let red = Color(r: 255, g: 0, b: 0)
      static let green = Color(r: 0, g: 255, b: 0)
      static let blue = Color(r: 0, g: 0, b: 255)
  }
  </code></pre>
  <p>Any help will be greatly appreciated.</p>