[NSMutableURLRequest released]: сообщение, отправленное на deallocated instance

Мое приложение вызывает метод rqst_run ниже в методе didViewLoad, но у меня есть ошибка. Отладчик сообщает об ошибке:

[NSMutableURLRequest released]: message sent to deallocated instance

Я не знаю, где эта переменная выходит

Объявлена в заголовочном файле (раздел интерфейса):

NSMutableString        *rqst_error;
NSMutableData      *rqst_data;
NSMutableDictionary    *listing_items;

и я определил этот метод в реализации:

- (void)rqst_run
{
    rqst_data = [[NSMutableData data] retain];
    NSMutableURLRequest *http_request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.feedserver.com/request/"]];
    [http_request setHTTPMethod:@"POST"];
    NSString *post_data = [[NSString alloc] initwithFormat:@"param1=%@&param2=%@&param3=%@",rqst_param1,rqst_param2,rqst_param3];
    [http_request setHTTPBody:[post_data dataUsingEncoding:NSUTF8StringEncoding]];
    rqst_finished = NO;
    [post_data release];
    NSURLConnection *http_connection = [[NSURLConnection alloc] initWithRequest:http_request];
    [http_request release];

    if(http_connection)
    {
        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];

        if([rqst_data length]>0)
        {
            NSString *rqst_data_str = [[NSString alloc] rqst_data encoding:NSUTF8StringEncoding];   
            SBJsonParser *json_parser = [[SBJsonParse alloc] init];
            id feed = [json_parser objectWithString:rqst_data_str error:nil];
            listing_items = (NSMutableDictionary *)feed;
            [json_parser release];
            [rqst_data_str release];
        }   
        else
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Feed" message:@"No data returned" delegate:self cancemButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];
            [alert release];
        }
   }
   else
   {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Problem" message:@"Connection to server failed" delegate:self cancemButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
   }
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [rqst_data setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [rqst_data appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    [rqst_data release];
    [connection release];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [rqst_data release];
    [connection release];
    rqst_finished = YES;
}
0
задан Steve 6 September 2011 в 08:02
поделиться