I am tasked with cleaning up someone else's Objective-C code, and will admit it is not my language of choice. I am not sure if this is a valid question but was hoping someone could double check my attempt to clean up a method written by someone else, and make sure I didn't miss some minor detail or over simplify the code.
The original method written by someone else
if([[UserManager sharedManager]isUserLoggedIn] && ([APPDELEGATE isCommerceZone]))// Auth and commerce { [self showPopUpAddToCartOrExpressOrder:NO]; UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, _addToCartOrExpressOrderView); } else if([[UserManager sharedManager]isUserLoggedIn] && (![APPDELEGATE isCommerceZone])) // Auth and noncommerce { [self onModifyItemDone:nil]; } else if (![[UserManager sharedManager]isUserLoggedIn] && ([APPDELEGATE isCommerceZone]))// guest and commerce { [self showPopUpAddToCartOrExpressOrder:YES]; UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, _addToCartOrExpressOrderView); } else if (![[UserManager sharedManager]isUserLoggedIn] && (![APPDELEGATE isCommerceZone]))// guest and noncommerce { /// Do nothing }
My revision
if([APPDELEGATE isCommerceZone])
{
[self showPopUpAddToCartOrExpressOrder:![[UserManager sharedManager]isUserLoggedIn]];
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,_addToCartOrExpressOrderView);
} else if([[UserManager sharedManager]isUserLoggedIn]) // Auth and noncommerce
{
[self onModifyItemDone:nil];
}
In Objective-C, is this the equivalent to saying this boolean equals the opposite of this other boolean?
[self showPopUpAddToCartOrExpressOrder:![[UserManager sharedManager]isUserLoggedIn]];