Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should we copy blocks rather than retain?

I recently met a problem using blocks with Facebook's app switching. I needed to call a block after the Facebook login.

First my block was destroyed when the app switched back ('cause it was on the stack), so I decided to retain it. But that didn't work, and I messed with that problem :/. I found a solution on that blog and also here.

My question is simply : why copy works and retain does not ?

like image 640
Jeremy Avatar asked Dec 04 '22 00:12

Jeremy


1 Answers

Because when you create a block there is nothing to retain, since it doesn't exist in the heap until you copy it there with Block_copy. This is covered in the WWDC lectures about blocks.

More info: http://www.friday.com/bbum/2009/08/29/blocks-tips-tricks/

like image 175
borrrden Avatar answered Dec 11 '22 12:12

borrrden