From 8da2c2c0d4fd6a35e45c7cce3370e9eba3c01834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=85=8B?= Date: Sun, 20 May 2012 00:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _posts/2012-05-18-life-before-arc.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_posts/2012-05-18-life-before-arc.md b/_posts/2012-05-18-life-before-arc.md index e475254..0702a4c 100644 --- a/_posts/2012-05-18-life-before-arc.md +++ b/_posts/2012-05-18-life-before-arc.md @@ -116,9 +116,9 @@ AutoreleasePool是可以嵌套的,你可以想象成每创建一个NSAutorelease {% highlight objc %} for (int i = 0; i < numberOfImages; ++i) {
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - /*
 * Loading images, etc.
 * Too many autoreleased objects exist. */ + //Loading images, etc.
 //Too many autoreleased objects exist. [pool drain]; - /*
 * All the autoreleased objects are released by [pool drain]. */ + //All the autoreleased objects are released by [pool drain]. } {% endhighlight %} @@ -134,9 +134,9 @@ AutoreleasePool的实现为AutoreleasePoolPage类,是用C++来实现的。 {% highlight objc %} -NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; /* 等价于 objc_autoreleasePoolPush() */ +NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //等价于objc_autoreleasePoolPush() id obj = [[NSObject alloc] init]; -[obj autorelease];
/* 等价于 objc_autorelease(obj) */ -[pool drain];
/* 等价于 objc_autoreleasePoolPop(pool) */ +[obj autorelease];//等价于 objc_autorelease(obj) +[pool drain];// 等价于 objc_autoreleasePoolPop(pool) {% endhighlight %}