Your URL, http://gymnasium2.ai.ch/~mensa/countdown_timestamp.html , is a complete HTML file. NSString initWithContentsOfURL: will return a string containing all its contents:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>1328633219</title> </head> <body> 1328633219 </body> </html>
It cannot be converted to double; you will need to parse the HTML code, which can be quite large.
It would be easier to place a simple file containing only a number:
1328633219
Then your code above will be able to get the number without any changes.
However, the following code may interfere with your code:
NSString *string = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://gymnasium2.ai.ch/~mensa/countdown_timestamp.html"]]; label.text = string;
If label is nil , then timeInterval will not be set properly, because [label.text doubleValue] will also return nil . Instead, you can try:
NSString *string = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://gymnasium2.ai.ch/~mensa/countdown_timestamp.html"]]; double timeInterval = string; label.text = [NSString stringWithFormat:@"%d", (int)timeInterval];
It would be useful to reset the breakpoint or add an NSLog call after retrieving the file so you can see what is happening.
NSString *string = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://gymnasium2.ai.ch/~mensa/countdown_timestamp.html"]]; NSLog(@"Downloaded file with contents: %@", string);
Alternatively, you can load the plist file and use something like NSDictionary dictionaryWithContentsOfURL: or NSArray arrayWithContentsOfURL: See the list property list guide .