----- CAPITULO 10 -------


Ejercicio numero 1

Codigo de Ejercicio:

    
    //
    //  ViewController.swift
    //  RandomNumber
    
    //  JEHOVANI DE JESUS CHAVEZ SEGOVIA 2561842011
    
    import UIKit
    
    class ViewController: UIViewController {
    
        @IBOutlet var randomNumber: UILabel!
        
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
        @IBAction func seed(sender: UIButton) {
            
            srandom(CUnsignedInt(time(nil)))
            randomNumber.text="Estamos Generando"
            
        }
    
        @IBAction func generate(sender: UIButton) {
            
            let date = NSDate()
            let calendar = NSCalendar.currentCalendar()
            
            let components = calendar.components(.CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitMonth | .CalendarUnitYear | .CalendarUnitDay, fromDate: date)
          
            let hour = components.hour
            let minutes = components.minute
            let day = components.day
            let month = components.month
            let year = components.year
            
            randomNumber.text="\(day)/\(month)/\(year)  \(hour):\(minutes) "
        }
    }
    
    
    
    
                                

Corriendo aplicacion