I have the following code.
NSData *pageData = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
NSString *webpage = [[NSString alloc] initWithData:pageData encoding:NSUTF8StringEncoding];
This works fine with most pages but truncates the really long ones, is there a way around this at all?
I believe this is what you are looking for (from the NSString class reference linked above):
stringWithContentsOfURL:encoding:error:Returns a string created by reading data from a given URL interpreted using a given encoding.
(id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)errorParameters
url The URL to read.enc The encoding of the data at url.
error If an error occurs, upon returns contains an
NSErrorobject that describes the problem. If you are not interested in possible errors, you may pass inNULL.Return Value
A string created by reading data from URL using the encoding, enc. If the URL can’t be opened or there is an encoding error, returnsnil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With