Skip to content

Instantly share code, notes, and snippets.

@ThinhPhan
Created August 18, 2015 10:35
Show Gist options
  • Save ThinhPhan/0cafe820b229ccf7fd9f to your computer and use it in GitHub Desktop.
Save ThinhPhan/0cafe820b229ccf7fd9f to your computer and use it in GitHub Desktop.
Check string is 'empty'.
// 'Nothing' in Objective-C have a lot of meaning.
// Read [nil / Nil / NULL / NSNull] http://nshipster.com/nil/
// With string, nothing can be nil or "" - empty string.
// Bad
if ([string isEqualToString:@""] && password == nil) {
}
// Good - Simple check 'length' for both conditions above.
if ([string length] == 0) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment