为什么我在Web服务“EXC_BAD_ACCESS”中出错...?

时间:2011-12-03 05:33:36

标签: objective-c xml xcode

先谢谢

当我试图通过“exc_bad_access”调用webservice时出错。我把我的代码放在下面。

这是我收到错误的一小部分:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"DONE. Received Bytes: %d", [webData length]);

    NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];

    NSLog(@"%@",theXML);

    [theXML release];

    if( xmlParser )

    {

        [xmlParser release];

        }

    xmlParser = [[NSXMLParser alloc] initWithData: webData];     <--- Error here.

    [xmlParser setDelegate:self];

    [xmlParser setShouldResolveExternalEntities: YES];

    [xmlParser parse];

    [activityIndicator stopAnimating];

    [connection release];

    [webData release];
}

1 个答案:

答案 0 :(得分:0)

尝试添加:

xmlParser = nil;

之后
[xmlParser release];