title: What's Apple's recommendation to use: custom struct or extension?
body: <p>What's recommended?</p>
  
  <ul>
  <li>Option 1: custom struct</li>
  <li>Option 2: extension to a class</li>
  </ul>
  
  <p>This example below is simply a example function that returns a UIColor from the red, green and blue values, without you having to divide the number by 255. The code is written in Swift 5.</p>
  
  <p>For example:</p>
  
  <pre><code>struct colorFrom {
  
      func RGB(r: CGFloat, g: CGFloat, b: CGFloat) -&gt; UIColor {
  
          var red, green, blue, alpha: CGFloat
          red = r / 255
          green = g / 255
          blue = b / 255
          alpha = 1
  
          var color: UIColor
          color = UIColor(red: red, green: green, blue: blue, alpha: alpha)
  
          return color
  
      }
  
  }
  
  extension UIColor {
  
      func RGB(r: CGFloat, g: CGFloat, b: CGFloat) -&gt; UIColor {
  
          var red, green, blue, alpha: CGFloat
          red = r / 255
          green = g / 255
          blue = b / 255
          alpha = 1
  
          var color: UIColor
          color = UIColor(red: red, green: green, blue: blue, alpha: alpha)
  
          return color
  
      }
  
  }
  
  colorFrom().RGB(r: 153, g: 153, b: 153)
  UIColor().RGB(r: 153, g: 153, b: 153)
  </code></pre>