Reputation: 2520
Sometimes the function has this structure:
func prueba(................, error: Error?){
//Code here
//How I can validate if error really exist?
}
If I use if
to make error!=nil
, always is not true but the error don't exist.
Upvotes: 0
Views: 59
Reputation: 318824
For functions that actually have an optional Error
parameter, you can do something like this:
if let error = error {
// there is an error, handle as needed
print("Error: \(error)")
} else {
// no error
}
Upvotes: 3