Hi, i have developed an applikation which loads a specified url with an XML Parser. This URL changes sometimes, and every 4 seconds it reloads.(via NSTIMER)
On the simulator it works perfectly but on the device it is always the same ( like a kind of caching)
-(void)parseXMLFileAtURL:(NSString *) URL{
NSLog(@"Parsed XML URL: %@", URL);
currentURL=[URL copy];;
tutorials= [[NSMutableArray alloc] init];
settings= [[NSMutableArray alloc] init];
NSURL *xmlURL=[NSURL URLWithString:URL];
xmlParser =[[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[xmlParser setDelegate:self];
[xmlParser parse];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict{
currentElement= [elementName copy];
if([elementName isEqualToString:@"item"]){
item=[[NSMutableDictionary alloc] init];
currentTitle=[[NSMutableString alloc] init];
currentImage=[[NSMutableString alloc] init];
currentLink=[[NSMutableString alloc] init];
currentDetails=[[NSMutableString alloc] init];
}
if([elementName isEqualToString:@"setting"]){
setting=[[NSMutableDictionary alloc] init];
currentTitle=[[NSMutableString alloc] init];
currentTyp=[[NSMutableString alloc] init];
currentLink=[[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if([elementName isEqualToString:@"item"]){
NSLog(@"currenttitle: %@",currentTitle );
[item setObject:currentTitle forKey:@"title"];
[item setObject:currentImage forKey:@"image"];
[item setObject:currentLink forKey:@"link"];
[item setObject:currentDetails forKey:@"details"];
[tutorials addObject:[item copy]];
}
if([elementName isEqualToString:@"setting"]){
NSLog(@"Currentsettingtitle: %@",currentTitle );
[setting setObject:currentTitle forKey:@"title"];
[setting setObject:currentTyp forKey:@"typ"];
[setting setObject:currentLink forKey:@"link"];
[settings addObject:[setting copy]];
}
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if([currentElement isEqualToString:@"title"]){
[currentTitle appendString:string];
}
if([currentElement isEqualToString:@"image"]){
[currentImage appendString:string];
}
if([currentElement isEqualToString:@"link"]){
[currentLink appendString:string];
}
if([currentElement isEqualToString:@"typ"]){
[currentTyp appendString:string];
}
if([currentElement isEqualToString:@"details"]){
[currentDetails appendString:string];
}
}
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
NSLog(@"Fertig mit Document");
for (int i=0; i<[settings count]; i++) {
NSString *typ =(NSString*)[[settings objectAtIndex:i ] objectForKey:@"typ"];
typ=[typ stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
if([typ isEqualToString:@"Button1"])
button1.title=(NSString*)[[settings objectAtIndex:i ] objectForKey:@"title"];
if([typ isEqualToString:@"Button2"])
button2.title=(NSString*)[[settings objectAtIndex:i ] objectForKey:@"title"];
if([typ isEqualToString:@"Button3"])
button3.title=(NSString*)[[settings objectAtIndex:i ] objectForKey:@"title"];
if([typ isEqualToString:@"Titel"])
navitem.title=(NSString*)[[settings objectAtIndex:i ] objectForKey:@"title"];
}
//[[tutorials ] objectForKey:@"title"]
[myTableView reloadData];
}
Anybody an Idea?