Why such line of code needed?

Discussion in 'iOS Programming' started by erdinc27, Mar 30, 2018.

  1. erdinc27 macrumors regular

    Jul 20, 2011
    Hey guys. There is a project that I develop. I am the 3rd developer working on it. I have a line of code that exist almost in each method in view controllers.
    __weak xViewController *weakSelf = self;
    why such a code needed?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    This is sometimes know as the 'weak self strong self dance'. It is used inside objective c blocks that are executed asynchronously to prevent retain cycles. There is a ton of info on this topic online. Search for 'retain cycles weak' or similar.

Share This Page