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