title: How Can I Change a String Using Remote Config?
body: <p>I'm creating an app that plays a sound when a button is clicked. It consists of <code>UIButton</code> to play the sound, <code>UIImageView</code> to display the associated image, and another <code>UIButton</code> which I'm using like a label to describe the button. I want to be able to configure all three parameters so I can change them remotely from Firebase. So far I figured out how to change the label, but I want to be able to change the URL that the sound and image load from. Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>import UIKit
  import Firebase
  import AVKit
  
  class FirebaseViewController: UIViewController, AVAudioPlayerDelegate {
  
      //These variables are for my sound when I click a button
      var firesound1 = AVPlayer()
      var firesound2 = AVPlayer()
      var firesound3 = AVPlayer()
      
      //These outlets reference the labels(UIButton) and UIImageView in the storyboard
      @IBOutlet weak var firelabel1: UIButton!
      @IBOutlet weak var firelabel2: UIButton!
      @IBOutlet weak var firelabel3: UIButton!
      @IBOutlet weak var fireimage1: UIImageView!
      @IBOutlet weak var fireimage2: UIImageView!
      @IBOutlet weak var fireimage3: UIImageView!
      
      func updateViewWithRCValues() {
          
  //These remote config options allow me to change the text of the UIButton, which here I'm using like a UILabel
          firelabel1.setTitle(buttonLabel1, for: .normal)
          let buttonLabel2 = RemoteConfig.remoteConfig().configValue(forKey: "label2").stringValue ?? ""
          firelabel2.setTitle(buttonLabel2, for: .normal)
          let buttonLabel3 = RemoteConfig.remoteConfig().configValue(forKey: "label3").stringValue ?? ""
          firelabel3.setTitle(buttonLabel3, for: .normal)
          let url = RemoteConfig.remoteConfig().configValue(forKey: "url1").stringValue ?? ""
          firelabel3.setTitle(buttonLabel3, for: .normal)
      }
     
      func setupRemoteConfigDefaults() {
          let defaultValues = [
          "label1": "" as NSObject,
          "label2": "" as NSObject,
          "label3": "" as NSObject
          ]
          RemoteConfig.remoteConfig().setDefaults(defaultValues)
      }
      
      func fetchRemoteConfig() {
          // Remove this before production!!
          let debugSettings = RemoteConfigSettings(developerModeEnabled: true)
          RemoteConfig.remoteConfig().configSettings = debugSettings!
          
          RemoteConfig.remoteConfig().fetch(withExpirationDuration: 0) { [unowned self] (status, error) in guard error == nil else {
              print ("Error fetching remote values: \(String(describing: error))")
              return
              }
              print("Retrieved values from the cloud")
              RemoteConfig.remoteConfig().activateFetched()
              self.updateViewWithRCValues()
          }
      }
  
          override func viewDidLoad() {
              super.viewDidLoad()
              setupRemoteConfigDefaults()
              fetchRemoteConfig()
              
  //This code loads an image from a url into a UIImageView. I want to be able to configure the url like a parameter so I can change the url from the firebase website.
              let url = URL(string: "https://ichef-1.bbci.co.uk/news/976/media/images/83351000/jpg/_83351965_explorer273lincolnshirewoldssouthpicturebynicholassilkstone.jpg")
              let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
                  if (error != nil)
                  {
                      print("ERROR")
                  }
                      else
                      {
                          var documentsDirectory: String?
                          var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
                          if paths.count &gt; 0
                          {
                              documentsDirectory = paths [0]
                              let savePath = documentsDirectory! + "/ImageOne"
                              
                              FileManager.default.createFile(atPath: savePath, contents: data, attributes: nil)
                              DispatchQueue.main.async
                                  {
                                      self.fireimage1.image = UIImage(named: savePath)
                              }
                      }
                  }
              }
             task.resume()
      
  }
     
      //This code plays the sounds. I also want to be able to configure the url like a parameter.
      @IBAction func soundpressed1(_ sender: Any) {
          
          let sound1 = AVPlayerItem(url: URL(string: "https://firebasestorage.googleapis.com/v0/b/mlg-soundboard-2018-edition.appspot.com/o/hitmarker.mp3?alt=media&amp;token=e5d342d6-4074-4c50-ad9d-f1e41662d9e9")!)
          firesound1 = AVPlayer(playerItem: sound1)
          firesound1.play()
      }
  
      override func didReceiveMemoryWarning() {
              
      }    
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Basically I want to be able to swap out the URLs with Remote Config.</p>