Pass data from one window to another in XCODE

0

My question is how I can send data by clicking "tap" on some item and that it passes the data from one window to another

this is my code

//
//  ViewController3.swift
//  dali
//
//  Created by Francisco Navarrete on 10/8/18.
//  Copyright © 2018 Francisco Navarrete. All rights reserved.
// PANTALLA PALICULAS 

import UIKit

class ViewController3: UIViewController, UITableViewDataSource {
    
    final let url = URL(string: "https://dalid1581.000webhostapp.com/movies.json")
    private var movies = [Movie]()
    @IBOutlet var tableView: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        downloadJson()
    }
    
    func downloadJson(){
        
        guard let downloadURL = url else { return }
        URLSession.shared.dataTask(with: downloadURL) { (data, urlResponse, error) in
            guard let data = data, error == nil, urlResponse != nil else {
                print("error como tu vida")
                return
            }
             print("downloaded")
            do{
                let decoder = JSONDecoder()
                let downloadedMovies = try decoder.decode(Movies.self, from: data)
                self.movies = downloadedMovies.movies
                DispatchQueue.main.async {
                    self.tableView.reloadData()
                }
            }catch{
                print("Error after downloaded")
            }
            
        }.resume()
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return movies.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "MovieCell") as? MovieCell else { return UITableViewCell() }
        
        cell.titleLbl.text = movies[indexPath.row].title
        
        if let imageURL = URL(string: movies[indexPath.row].image){
            DispatchQueue.global().async {
                let data = try? Data(contentsOf: imageURL)
                if let data = data{
                    let image = UIImage(data: data)
                    DispatchQueue.main.async {
                        cell.imgView.image = image
                    }
                }
            }
        }
        
        return cell
    }
}
    
asked by Francisco Navarrete 14.10.2018 в 00:08
source

0 answers