Hi, I've been writing validation related "if conditions" in two different ways and I wonder what would be the better way to do. I want to improve my code quality.
first method:
second method:
If non of these methods are correct, please tell me the best way to write it. Thanks.
first method:
Code:
-(void) someMethod {
...
if ( [[NSFileManager defaultManager] fileExistsAtPath:path] ) {
// send email
...
} else {
// show error
...
}
}
second method:
Code:
-(void) someMethod {
...
if ( ![[NSFileManager defaultManager] fileExistsAtPath:path] ) {
// show error
...
return;
}
// send mail
...
}
If non of these methods are correct, please tell me the best way to write it. Thanks.