은 다음 프로세스를 나타냅니다.
@interface YourViewController : UITableViewController<NSURLConnectionDelegate,NSXMLParserDelegate>
//some declartion property...
@end
@implementation YourViewController
- (void)viewDidLoad
{
[super viewDidLoad];
isParsingStart = NO;
webData = [[NSMutableData alloc] init];
connection = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:YOUR_XML_URL] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:20] delegate:self];
}
- (void)tappingButton:(UIButton *)sender
{
if(isParsingStart)
{
//show a alert view... or other do stuff
return;
}
webData = [[NSMutableData alloc] init];
connection = [[[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:YOUR_XML_URL] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:20] delegate:self] autorelease];
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
parser = [[NSXMLParser alloc] initWithData:webData];
parser.delegate = self;
if([parser parse])
{
isParsingStart = NO;
NSLog(@"The XML is Parsed.");
[[self tableView] reloadData];
}
else
{
isParsingStart = NO;
NSLog(@"Failed to parse the XML");
}
[webData setData:nil];
}
- (void)parserDidStartDocument:(NSXMLParser *)parser
{
isParsingStart = YES;
}
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
//do stuff
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
// do stuff
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
// do stuff
}
.
.
.
는 테이블보기 이미지 포함되어 있습니까? – rakeshNS
예 테이블 뷰 – umefarooq