为什么我们应该复制块而不是保留? [英] Why should we copy blocks rather than retain?

查看:88
本文介绍了为什么我们应该复制块而不是保留?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在使用Facebook的应用程序切换功能时遇到了一个问题. Facebook登录后,我需要调用一个阻止程序.

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.

我的问题很简单:为什么复制有效,但保留无效?

推荐答案

由于创建块时,没有要保留的内容,因为直到使用Block_copy将其复制到堆中为止,堆中都不存在该块. WWDC关于块的讲座对此进行了介绍.

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.

更多信息: http://www.friday. com/bbum/2009/08/29/blocks-tips-tricks/

这篇关于为什么我们应该复制块而不是保留?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆