Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
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.
Code:
__weak xViewController *weakSelf = self;

why such a code needed?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.
 
  • Like
Reactions: sundialsoft
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.