gpt4 book ai didi

iphone - NSData 到 NSString 被截断 - iPhone

转载 作者:行者123 更新时间:2023-12-03 19:35:46 24 4
gpt4 key购买 nike

我有以下代码。

NSData *pageData = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
NSString *webpage = [[NSString alloc] initWithData:pageData encoding:NSUTF8StringEncoding];

这适用于大多数页面,但会截断很长的页面,有没有办法解决这个问题?

最佳答案

我相信这就是您正在寻找的内容(来自上面链接的 NSString 类引用):

stringWithContentsOfURL:encoding:error:

Returns a string created by reading data from a given URL interpreted using a given encoding.

(id)stringWithContentsOfURL:(NSURL *)<i>url</i> encoding:(NSStringEncoding)<i>enc</i> error:(NSError **)<i>error</i>

Parameters
url The URL to read.

enc The encoding of the data at url.

error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.

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, returns nil.

关于iphone - NSData 到 NSString 被截断 - iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1133696/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com