Append array int to a string array

Right now I have a string array that displays a string on a individual line. I would like to take a int array and display on the same line. So the entries of the array are pared in order. So yourArray[1] = number[1], yourArray[2] = number[2], etc. So I am just trying to add a the number array to labez.text = sortedArray.map { " ($0)" }.joined(separator:“\n”) line of code. Thanks.

        var yourArray = [String]()
        var number = [Int]()


          @IBAction func store(_ sender: Any) {
        yourArray.append((textA.text!))
        number.append(Int(textB.text!)!)





        labez.text = sortedArray.map { " \($0)" }.joined(separator:"\n")


        let sortedArray:[String] = yourArray.sorted { $0.localizedCaseInsensitiveCompare($1) == ComparisonResult.orderedAscending }


    }

Hey, I replied to your other topic with a solution that might help: Struct not keeping tuple in order (swift3) - #2 by liamnichols

I’ve noticed that you have a few topics relating to the same task that you are trying to see. It might be worth creating a single topic explaining your actual main goal so that people can help provide some suggestions about potential implementations and I’m not sure the structure of what you are trying to do is quite right. Let me know if I can help further!

This topic was automatically closed after 166 days. New replies are no longer allowed.