How to load and get data from 2 files
Time to learn how to DRY off your WET code!
(DRY -&gt; &quot;Don't Repeat Yourself&quot;; WET -&gt; &quot;Write Everything Twice&quot;)
Note how the only difference between your two functions is a URL and a change in data, effectively &quot;changing input results in changing output.&quot; Consider consolidating the two into one generic function that takes a variable url in as input and returns data which can be store in a variable of your choice.
var saleNumber1 = &quot;&quot;
var saleNumber2 = &quot;&quot;

override func viewDidLoad() {
    super.viewDidLoad()
        
    saleNumber1 = sale(&quot;http://example.com/folder/sale1.txt&quot;)
    saleNumber2 = sale(&quot;http://example.com/folder/sale2.txt&quot;)
}

func sale(path: String) -&gt; String {
    let url = URL(string: path)!
    let saleNumber = &quot;&quot;
    let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
        guard let data = data else { return }
        saleNumber = &quot;\(String(data: data, encoding: .utf8)!)&quot;
    }

    task.resume()

    return saleNumber
}