我想下载一个在GitHub中共享的xml文件。这是我的代码,但我的结果是网站的xml。我哪里错了?
这是我的代码:
NSString *urlToDownload = @"https://github.com/qazaleh/xml-file/blob/master/result.xml";
NSURL *url = [NSURL URLWithString:urlToDownload];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"result"];
NSLog(@"Downloading Started %@",filePath);
//saving is done on main thread
[urlData writeToFile:filePath atomically:YES];
}
}