Objective c 如何自动刷新从NSXMLParser获取的字符串
我已经成功创建了一个Cocoa应用程序,它使用NSXMLParser从在线XML文件检索数据。现在,我试图弄清楚如何自动刷新XML数据 以下是我的实现文件中的一些相关方法:Objective c 如何自动刷新从NSXMLParser获取的字符串,objective-c,cocoa,nsxmlparser,Objective C,Cocoa,Nsxmlparser,我已经成功创建了一个Cocoa应用程序,它使用NSXMLParser从在线XML文件检索数据。现在,我试图弄清楚如何自动刷新XML数据 以下是我的实现文件中的一些相关方法: - (void)awakeFromNib { NSURL *xmlURL = [NSURL URLWithString:@"my_url_here"]; NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
- (void)awakeFromNib {
NSURL *xmlURL = [NSURL URLWithString:@"my_url_here"];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[parser setDelegate:self];
[parser parse];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
}
那么,如何每隔15分钟自动刷新一次XML?以重复间隔签出NSTimer 每15分钟(900秒)调用一个名为getMessage的方法的示例:
是的,NSTimer方法正是我想要的。效果很好。谢谢
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:900
target:self
selector:@selector(getMessage:)
userInfo:nil repeats:YES];
self.repeatingTimer = timer;