Use an image to open url, some do not have your url and I want you to show a message that you do not have it but I do not know how to do it
In Swift you can validate with isEmpty and show a UIAlertView ():
if (textField.text.isEmpty) {
let alert = UIAlertView()
alert.title = "Error"
alert.message = "No existe url definida"
alert.addButtonWithTitle("Ok")
alert.show()
}
Using Swift 2.0, if:
if let urlImagen = textField.text where textField.text.isEmpty {
// crea UIAlertView()
}
Swift 2.0, guard:
guard let urlImagen = textField.text where textField.text.isEmpty else {
// crea UIAlertView()
return
}
To load an image url into a UIImage , this is a example:
if let url = NSURL(string: "http://www.mydominio.com/myimagen.jpg") {
if let data = NSData(contentsOfURL: url) {
imageURL.image = UIImage(data: data)
}
}
Very simple ... check if the url field of your data is empty and if so use a UIAlertView, if you want with a delegate = nil, something like this:
if miUrl.isEmpty {
let alert = UIAlertView("Aviso!!!", message: "Mmmm, no tengo url!", delegate: nil,
cancelButtonTitle: "OK")
alert.show()
}else{
//hacer algo
}