title: Issue with value types and init’s
body: <p>I’m following an <a href="https://youtu.be/-8qnERZ6u8Q" rel="nofollow noreferrer">old tutorial</a> on setting up a data structure to view RGBA values in an image.  For the most part of gotten past all of the out of data stuff, but I’ve run into an issue that seems super simple, I’m just relatively new to swift, so it’s proving to be a bit more difficult.</p>
  
  <pre><code>import UIKit
  
  public struct RGBAPixel {
      public init(rawVal : UInt32) {
          raw = rawVal
      }
      public var raw: UInt32
      public var red: UInt8 {
          get { return UInt8(raw &amp; 0xFF) }
          set { raw = UInt32(newValue) | (raw &amp; 0xFFFFFF00) }
      }
      public var green: UInt8 {
          get { return UInt8( (raw &amp; 0xFF00) &gt;&gt; 8) }
          set { raw = (UInt32(newValue) &lt;&lt; 8) | (raw &amp; 0xFFFF00FF) }
      }
      public var blue: UInt8 {
          get { return UInt8( (raw &amp; 0xFF0000) &gt;&gt; 16) }
          set { raw = (UInt32(newValue) &lt;&lt; 16) | (raw &amp; 0xFF00FFFF) }
      }
      public var alpha: UInt8 {
          get { return UInt8( (raw &amp; 0xFF000000) &gt;&gt; 24) }
          set { raw = (UInt32(newValue) &lt;&lt; 24) | (raw &amp; 0x00FFFFFF) }
      }
  }
  
  let image = UIImage(named: "crossSection.jpg")
  
  let height = Int((image?.size.height)!)
  let width = Int((image?.size.width)!)
  let bitsPerComponent = Int(8)
  let bytesPerRow = 4 * width
  let colorSpace = CGColorSpaceCreateDeviceRGB()
  let rawData = UnsafeMutablePointer&lt;UInt32&gt;.allocate(capacity: width * height)
  let bitmapInfo: UInt32 = CGBitmapInfo.byteOrder32Big.rawValue | CGImageAlphaInfo.premultipliedLast.rawValue
  let CGPointZero = CGPoint(x: 0,y: 0)
  let rect = CGRect(origin: CGPointZero, size: (image?.size)!)
  
  let imageContext = CGContext(data: rawData, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
  
  imageContext?.draw(image!.cgImage!, in:rect)
  
  let pixels = UnsafeMutableBufferPointer&lt;UInt32&gt;(start: rawData, count: width * height)
  
  ///*
  for var y in 0 ..&lt; height {
      for var x in 0 ..&lt; width {
          var p = pixels[x+y*width] = RGBAPixel(rawVal: 0)
          p.red = 255
          pixels[x+y*width] = p
  
  
      }
  }
  //*/
  
  let outContext = CGContext(data: pixels.baseAddress, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
  
  let outImage = UIImage(cgImage: outContext!.makeImage()!)
  </code></pre>
  
  <p>There are two issue points.  First is the issue near the bottom when put into swift it gives the error “Cannot assign value of type ‘RGBAPixel’ to type ‘UInt32’”.  I followed the <a href="https://youtu.be/-8qnERZ6u8Q" rel="nofollow noreferrer">video</a> pretty well and looked for any errors I can’t seem to find.  It seems like this issue isn’t something that would be from an update so I’m very confused.
  I researched structs and inits and it seems to make sense the way the code is written.  The init is allowing the data type UInt32 to be passed in through RGBAPixel.  Again, very new so correct me <strong>where</strong> I’m wrong. Thanks</p>