我已經在其中我已經指定泄漏線的代碼的和平。由於我是iPhone開發的新手,我無法理解這條線究竟有什麼問題。請看看那條線並告訴我。這條泄漏線背後的原因是什麼?
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
//take away
//NSURL *url1 = [[NSURL alloc] initWithString:@"http://url/Service.asmx/takeAwayList"];
NSURL *url1 = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@/Service.asmx/takeAwayList",serviceURL]];
NSMutableURLRequest* request1=[NSMutableURLRequest requestWithURL:url1];
[request1 setHTTPMethod:@"POST"];
[request1 setTimeoutInterval:10];
//*****the leaky line***********************///
NSData *data2=[[NSURLConnection sendSynchronousRequest:request1 returningResponse:nil error:nil] autorelease];
if(data2 == nil)
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"The network is not available.\n Please check the Internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
NSXMLParser *xmlParser1 = [[NSXMLParser alloc] initWithData:data2];
//Initialize the delegate.
TakeAwayParser *takeAwayParser = [[TakeAwayParser alloc] initTakeAwayParser];
//Set delegate
[xmlParser1 setDelegate:takeAwayParser];
//Start parsing the XML file.
@try {
BOOL success = [xmlParser1 parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error Error Error!!!");
}
@catch (NSException * e) {
NSLog(@"Exception in parsing %@ %@",[e name], [e reason]);
}
[takeAwayParser release];
[xmlParser1 release];
}
//[request1 release];
// [response1 release];
//
[url1 release];
// [data2 release];
//new arrivals
//[data2 release];
[pool release];
這是愚蠢的,但我仍處於學習階段,所以你可以指定我應該從你重定向的頁面取什麼,我應該在我的代碼中替換什麼? – harshalb 2009-11-07 06:23:53
我覺得這個小代碼也有效。對於現在的手段是不是給我的網址任何進一步的泄漏把這個代碼後:NSMutableURLRequest * request1 = [NSMutableURLRequest requestWithURL:URL1的CachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0] \t [request1 setHTTPMethod:@「POST」]; \t // [request1 setTimeoutInterval:10]; \t [[NSURLCache sharedURLCache] setMemoryCapacity:0]; \t [[NSURLCache sharedURLCache] setDiskCapacity:0]; – harshalb 2009-11-07 07:23:18
這真的很古老,但是hib在這裏有什麼功能。對不起,復活一個死去的線程;) – gabaum10 2010-11-19 20:53:21