title: Looking to understand Swift Functions a bit better
body: <p>I'm new to swift and have a lot of repeating code.  For example how would you change the following code into different functions:</p>
  
  <h1>Example 1</h1>
  
  <pre><code>if let button = view.viewWithTag(12) as? UIButton {
              // change any properties of the button as you would normally do
              button.isHidden = true
          }
  </code></pre>
  
  <h1>Example 2</h1>
  
  <pre><code>var oneAPlayer = AVAudioPlayer()
  var oneBPlayer = AVAudioPlayer()
  var oneCPlayer = AVAudioPlayer()
  var oneDPlayer = AVAudioPlayer()
  var twoAPlayer = AVAudioPlayer()
  var threeAPlayer = AVAudioPlayer()
  var fourAPlayer = AVAudioPlayer()
  let oneASound = Bundle.main.path(forResource: "1-a", ofType: "mp3")
  let oneBSound = Bundle.main.path(forResource: "1-b", ofType: "mp3")
  let oneCSound = Bundle.main.path(forResource: "1-c", ofType: "mp3")
  let oneDSound = Bundle.main.path(forResource: "1-d", ofType: "mp3")
  let twoASound = Bundle.main.path(forResource: "2-a", ofType: "mp3")
  let threeASound = Bundle.main.path(forResource: "3-a", ofType: "mp3")
  let fourASound = Bundle.main.path(forResource: "4-a", ofType: "mp3")
  </code></pre>