1
특정 시점에서 libxml 파서의 연결을 중지해야합니다. 누구든지이 작업을 수행하는 방법을 제안 할 수 있습니까?iphone sdk의 어느 시점에서 libxml 파서의 연결을 중지하는 방법?
이것은 연결을 설정하는 데 사용한 방법입니다.
- (BOOL)parseWithLibXML2Parser
{
BOOL success = NO;
ZohoAppDelegate *appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate];
NSString* curl;
if ([self.lateFeeName length] == 0)
{
curl = @"https://invoice.zoho.com/api/view/settings/latefees?ticket=";
curl = [curl stringByAppendingString:appDelegate.ticket];
curl = [curl stringByAppendingString:@"&apikey=bfc9c6dde7c889a19f8deea9d75345cd"];
curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""];
}
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:curl]];
NSLog(@"the request parserWithLibXml2Parser %@",theRequest);
NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
self.connection = con;
[con release];
// This creates a context for "push" parsing in which chunks of data that are
// not "well balanced" can be passed to the context for streaming parsing.
// The handler structure defined above will be used for all the parsing. The
// second argument, self, will be passed as user data to each of the SAX
// handlers. The last three arguments are left blank to avoid creating a tree
// in memory.
_xmlParserContext = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL);
if(self.connection != nil)
{
do
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
} while (!_done && !self.error);
}
if(self.error)
{
[self.delegate parser:self encounteredError:nil];
} else
{
success = YES;
}
return success;
}
사실 나는 데이터의 로딩이 진행 중일 때 내가 뒤로 버튼을 눌러 예외를 얻고있다.
// Called when a chunk of data has been downloaded.
- (void)connection:(NSURLConnection *)connection
didReceiveData:(NSData *)data
{
// Process the downloaded chunk of data.
xmlParseChunk(_xmlParserContext, (const char *)[data bytes], [data length], 0);//....Getting Exception at this line.
}
누구나 도움이 될 것입니다.
감사합니다. Monish.