Hi .. Let your
url / address is
http://www.example.com/ , and ur
file name is
link.txt. when ur application load u can change the file name in any string then append the string .. then load the url to ur web view.
Code Bellow,
NSString *fileName = @"demo.txt";
NSString *address = @"https://www.example.com/";
address = [address stringByAppendingString:fileName];
NSLog(@"%@",address);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[self.webView loadRequest:request];
address should be like :-
http://www.example.com/link.txt[
]
Okay ,
then if u want to download the file on button click do this, download and the file to ur device
write this method on button action,
NSData *urlData = [NSData dataWithContentsOfURL:url];
NSString *filePath;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"filename.txt"];
NSLog(@"%@",filePath);
[urlData writeToFile:filePath atomically:YES];
If u want you web view to do this automatically, just give some delay after web view loaded and the above method.