----- CAPITULO 7 -------


Ejercicio numero 2

Codigo de Ejercicio:

  • Limpiar los label para que la aplicaion inici sin mostrar texto del label
  • 
    
    
    //JEHOVANI DE JESUS CHAVEZ SEGOVIA  2561842011
    
    //En este ejercicio limpiamos el texto del label borrando para que al iniciar no lo muestre 
    //y solo muestre el resultado al seleccionar el boton.
    
    //
    //  ViewController.swift
    //  RadioStations
    
    //Jehovani de Jesus Chavez Segovia 2561842011
    
    //Radio estacion agregar boton am fm y mostrar diferentes frecuencias
    
    import UIKit
    
    class ViewController: UIViewController {
    
        var myStation: RadioStation
        var myStation2: RadioStation
        
        @IBOutlet var stationName : UILabel!
             @IBOutlet var stationFrequency : UILabel!
        @IBOutlet var stationBand : UILabel!
        
        required init(coder aDecoder: NSCoder) {
            
            myStation = RadioStation()
            myStation.frequency=105.5
            myStation.name = "Knix"
            myStation2 = RadioStation()
            myStation2.frequency=580.0
            myStation2.name = "Knix2"
            
            super.init(coder: aDecoder)
        }
        
        
        
    
        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 buttonClick(sender: AnyObject) {
            stationName.text = myStation.name
            stationFrequency.text = String(format:"%f", myStation.frequency)
            
            if myStation.frequency >= RadioStation.minFMFrequency() && myStation.frequency <= RadioStation.maxFMFrequency() {
                stationBand.text = "FM"
            } else {
                stationBand.text = "AM"
            }
            
        }
    
        
        @IBAction func buttonClick2(sender: AnyObject) {
            stationName.text = myStation2.name
            stationFrequency.text = String(format:"%f", myStation2.frequency)
            
            if myStation2.frequency <= RadioStation.minAMFrequency() && myStation2.frequency >= RadioStation.maxAMFrequency() {
                stationBand.text = "FM"
            } else {
                stationBand.text = "AM"
            }
            
        }
    
        
        
    }
    
                                

Corriendo aplicacion sin que aparezca texto en el label

seleccionamos boton y nos muestra el resultado