My app checks if an NSString is empty when it launches, like this:
if ([checkfieldstring1 isEqualToString:@""]) {
checkboxButton.hidden = YES;
}
else {
checkboxbutton.hidden = NO;
}
However, when there is an empty string, the button is not being hidden. I know this method works when I hook it up as an IBAction to a button, but not on ViewDidLoad…
Checking for an empty string when the view is about to load needs to check for a nil string or an empty string as the string may not have been set up yet.
Or, if you do as I do and have this in a set of common macros that I add to a project:
Courtesy of Wil Shipley http://www.wilshipley.com/blog/2005/10/pimp-my-code-interlude-free-code.html
you could just check with: