NSError *err = nil;
NSString *url = [[NSString stringWithFormat:@"http://myurl.com/mypage"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *myTxtFile = [NSString stringWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:&err];
if(err != nil) {
//HANDLE ERROR HERE
}
Then to save it you can use:
[[NSUserDefaults standardUserDefaults] setObject:myTxtFile forKey:@"MyFile"];
And to retrieve it:
NSString *myTxtFile = [[NSUserDefaults standardUserDefaults] stringForKey:@"MyFile"];
Updated to reflect Joe's input
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…