ios - Concern about memory when choosing between notification vs callback closure for network calls? -
many posts seem advise against notifications when trying synchronize functions, there other posts caution against closure callbacks because of potential inadvertently retain objects , cause memory issues. assume inside custom view controller function, foo , uses bar class data server. class customviewcontroller : uiviewcontroller { function foo() { // other stuff // use bar data server bar.getserverdata() } } option 1: define getserverdata accept callback. define callback closure inside customviewcontroller . option 2: use nsnotifications instead of callback. inside of getserverdata , post nsnotification when server returns data, , ensure customviewcontroller registered notification. option 1 seems desirable reasons people caution against nsnotification (e.g., compiler checks, traceability), doesn't using callback create potential issue customviewcontroller unnecessarily retained , therefore potentially creating memory issues? ...