objective c - Should NSNotificationCenter selector be with or without an NSNotification object -
i'm doing code cleanup , wondering if there official or unofficial standard option below should preferable.
the basic issue have view change logic. code should called both in awakefromnib , whenever notification received. prevent writing same code twice option below preferable.
// option 1 - (void)receivethemechangenotification:(nsnotification *)note { [self updateinterfacewiththeme]; } - (void)updateinterfacewiththeme { } - (void)awakefromnib { [self updateinterfacewiththeme]; } // option 2 - (void)receivethemechangenotification:(nsnotification *)note { [self updateinterfacewiththeme]; } - (void)awakefromnib { [self receivethemechangenotification:nil]; } // option 3 // registered selector notification directly - (void)updateinterfacewiththeme { } - (void)awakefromnib { [self updateinterfacewiththeme]; }
answer pretty simple : if want send data notification ( e.g. id
, playerobject
, name
, anything
) use nsnotification
parameter.
as far can see don't need parameters since don't need nsnotification
.
selector
same add button or else. if need know sender, or need kind of information inside notification - use parameter. otherwise can skip it, , (like in case call unnecessary "bridge" function) better option.
Comments
Post a Comment