XML データの処理 (xml データの読み取りと sqlite 読み取りデータの挿入など) が完了したら、次のビューに移動したいと思います。
XML の解析が終了したかどうかを確認するにはどうすればよいですか?
コードを添付します。解析が完了したかどうかはどこで確認できますか?
-(IBAction)clickServerSync:(id)sender
{
if ([util checkNetwork]) {
[self LoadXml:@"LANG"];
[self LoadXml:@"CATEGORY"];
[self LoadXml:@"LIST"];
[self LoadXml:@"FILE"];
}
}
-(void)LoadXml:(NSString*)P_VAL
{
[indicator setHidden:NO];
NSString *smsURL = [NSString stringWithFormat:@"%@%@.asp", XML_URL, P_VAL];
NSString *sendAuthInfo = [NSString stringWithFormat:@"xx=%d" , 0 ];
NSString *val = [sendAuthInfo stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:smsURL]]autorelease];
[request setURL:[NSURL URLWithString:smsURL]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody: [val dataUsingEncoding:NSUTF8StringEncoding]];
[self startAsyncLoad:request tag:P_VAL];
}
- (void)startAsyncLoad:(NSMutableURLRequest*)request tag:(NSString*)tag {
CustomURLConnection *connection = [[CustomURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES tag:tag];
if (connection) {
[receivedData setObject:[[NSMutableData data] retain] forKey:connection.tag];
}
}
- (NSMutableData*)dataForConnection:(CustomURLConnection*)connection {
NSMutableData *data = [receivedData objectForKey:connection.tag];
return data;
}
-(void)check_xmlParserEnd
{
[indicator setHidden:YES];
}
- (void)connection:(CustomURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];
[dataForConnection setLength:0];
}
- (void)connection:(CustomURLConnection *)connection didReceiveData:(NSData *)data {
NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];
[dataForConnection appendData:data];
}
-(void)connectionDidFinishLoading:(CustomURLConnection*)connection
{
NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];
[connection release];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSXMLParser *xmlParser = [[[NSXMLParser alloc] initWithData:dataForConnection] autorelease];
XMLParser *parser = [[XMLParser alloc] initXMLParser];
[xmlParser setDelegate:(id)parser];
parser.viewDelegate = (id)self;
[xmlParser parse ];
}