Я выполнил инструкцию от Using NSURLConnection, а иногда (очень редко) мой проект разбивается по методу.Сбой NSURLConnection при выпуске NSMutableData
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[connection release];
[myNSMutableData release];
}
Он падает, когда я пытаюсь освободить мою NSMutableData
. Я хочу знать, почему он падает!
Некоторый код я использую:
- (void) start
{
while (1)
{
NSString *stringURL = @"http://www.iwheelbuy.com/get.php?sex=1";
NSURL *url = [NSURL URLWithString:stringURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5.0];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (connection)
{
getData = [[NSMutableData data] retain];
break;
}
else
{
NSLog(@"no start connection");
}
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
if ([connection.originalRequest.URL.absoluteString rangeOfString:@"get.php"].location != NSNotFound)
{
[getData setLength:0];
}
}
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
if ([connection.originalRequest.URL.absoluteString rangeOfString:@"get.php"].location != NSNotFound)
{
[connection release];
[getData release];
}
}
- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
if ([connection.originalRequest.URL.absoluteString rangeOfString:@"get.php"].location != NSNotFound)
{
[connection release];
NSString *html = [[NSString alloc] initWithData:getData encoding:NSASCIIStringEncoding];
[getData release];
if ([html rangeOfString:@"id1="].location != NSNotFound && [html rangeOfString:@"id2="].location != NSNotFound)
{
NSLog(@"everything is OKAY");
[html release];
}
else
{
[html release];
[self start];
}
}
}
Показать выходы консоли и отчеты о сбоях или трассировку стека от сбоя. Также запустите приложение под инструментом Zombies. –
Я продолжаю пытаться получить отчет о сбоях, но все еще не добившись успеха. Я не знаю, что такое инструмент Zombies ... – iWheelBuy
Мое приложение работает под зомби, что мне делать дальше? – iWheelBuy