download a web page with objective-c
How can i download the html content of a webpage giv开发者_如何学运维en an url? using objective c..
Use stringWithContentsOfURL:usedEncoding:error:
from NSString
NSURL * url = ... some url
NSError * error;
NSStringEncoding * encoding;
NSString * htmlContent = [NSString stringWithContentsOfURL:url usedEncoding:&encoding error:&error];
Assuming it's on iPhone or Mac OS X, use the sample here:
http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
Linking CURL with Objective C might be possible, but why?
Depends on what you are trying to do. For a web view:
webView = [[UIWebview alloc] loadRequest:(NSURLRequest *)request];
精彩评论