Skip to content

Instantly share code, notes, and snippets.

@cdzombak
Created June 19, 2012 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdzombak/2954739 to your computer and use it in GitHub Desktop.
Save cdzombak/2954739 to your computer and use it in GitHub Desktop.
switch vs if with pointers (if C allowed switch on ptrs)
// `item` is a UINavigationItem*
if (item == self.welcomeNavItem) {
return NO;
}
else if (item == self.emailNavItem) {
[self transitionToWelcomeScreen:YES];
return YES;
}
else if (item == self.passwordNavItem) {
[self transitionToEmailScreen:YES];
return YES;
}
// `item` is a UINavigationItem*
switch(item) {
case self.welcomeNavItem:
return NO;
case self.emailNavItem:
[self transitionToWelcomeScreen:YES];
return YES;
case self.passwordNavItem:
[self transitionToEmailScreen:YES];
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment