title: join two string - Swift
body: <p>i have an application for my shop and in the cart viewController i have a tableView cell showing the user what they add to the cart and i want to join the number of items with the name, i tried this code and it works 100% but instead of showing it like this --&gt; item1 (3 piece), item2 (4 piece), item3 (9 piece) .. it is show it like that item1,item2,item3 (349)</p>
  <p>this is my code for the tableViewController</p>
  <pre><code>import UIKit
  
  
  class cartTableViewController: UITableViewController {
  
  
  
  @IBOutlet var priceLabel: UILabel!
  @IBOutlet var totalOrder: UILabel!
  @IBOutlet var cartTableView: UITableView!
  
  override func viewDidLoad() {
      
      super.viewDidLoad()
      
      
    
  }
  
  // MARK: - Table view data source
  override func viewWillAppear(_ animated: Bool) {
      
      priceLabel.text = &quot;\(userData.selectedItemsPrice())&quot;
  
     totalOrder.text =  &quot;\(userData.allItemsToString()) (\(userData.allItemsToAmount())&quot; // this is the line i use it  
  
   
      
      super.viewWillAppear(animated)
  }
  }
  </code></pre>
  <p>struct code:</p>
  <pre><code>import UIKit
  
  struct userData {
  static var selectedItem: Item? = nil
  static var selectedItems: [Item] = []
  
  
  static func allItemsToAmount() -&gt; String {
      var allAmount: [String] = []
      for item in selectedItems {
          allAmount.append(item.amount)
      }
      return allAmount.joined(separator: &quot;&quot;)
  }
  
  static func selectedItemsPrice() -&gt; Double {
      var result: Double = 0
         for item in selectedItems {
          result = result + item.price
         }
         return result
  
  }
  
  
  static func storeName() -&gt; String {
      var Store: [String] = []
      for item in selectedItems {
          Store.append(item.Store)
      }
      
      return Store.joined()
      
      
  }
  
  
  static func allItemsToString() -&gt; String {
      var allNames: [String] = []
      for item in selectedItems {
          allNames.append(item.name)
      }
      
      return allNames.joined(separator: &quot;,&quot;  )
  
      
  }
  
  
  }
  
  struct Item: Equatable {
  /// All of the animals
  static let items : [Item] = {
      let bear: Item = .init(image: UIImage(named: &quot;bear&quot;), name: &quot;bear&quot;, price: 1, amount: &quot;&quot;, Store: &quot;&quot;)
      return [bear]
      
   
   
  }()
  
  var image: UIImage?
  var name: String
  var price: Double
  var amount: String
  var Store: String
  }
  </code></pre>