1
我的applicationDidFinishLaunching我打电话:此代码是否会泄漏内存?
[self performSelectorInBackground:@selector(performReachabilityCheck) withObject:nil];
这里是performReachabilityCheck
-(void)performReachabilityCheck{
internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
[self updateInterfaceWithReachability: internetReach];
}
我需要创建一个自动释放池?如果是这样,在这种情况下我该怎么做?
更新: 这是实现自动发布池的正确方法吗?
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[self performSelectorInBackground:@selector(performReachabilityCheck) withObject:nil];
[pool release]; pool = nil;
检查我更新的代码。我是否正确创建了自动发布池? – 2010-10-20 11:22:45
@Sheehan,你必须把NSAutoreleasePool放到你的performReachabilityCheck方法中(在后台运行) – Vladimir 2010-10-20 11:26:57