NSData for NSString truncated - iPhone

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 trims very long, is there any way around this at all?

+3
source share
2 answers

I believe this is what you are looking for (from the class NSStringreference above):

stringWithContentsOfURL:encoding:error:

Returns the string created by reading data from the given URL, interpreted using this encoding.

(id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error


URL url parameters for reading.

enc Encoding data by URL.

error If an error occurs, then the return contains an object NSErrorthat describes the problem. If you are not interested in possible errors, you can go through NULL.


, URL , enc. URL- error, nil.

+4

Source: https://habr.com/ru/post/1712718/


All Articles