检查 NSURL 加载完成
我正在 NSURL 中寻找“完成或完成”的东西 -> NSstring initWithContentsOfUrl
我找到了“URLResourceDidFinishLoading”,但这似乎已被贬值,
我找不到任何东西,但也许我搜索了错误的东西。
I'm looking for a "did finish, or finish" thing in NSURL -> NSstring initWithContentsOfUrl
I found "URLResourceDidFinishLoading" but this seems to be depreciated
I couldn't find any but maybe I searched for the wrong thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在谈论
NSString
中的-initWithContentsOfURL:
,则它已 已弃用。但即使您正在使用它,它也是一个同步方法 - 这意味着您的代码将暂停,直到数据加载到生成的
NSString
对象中:所以,需要明确的是:这是一个 不好的做法有两个原因:
您需要的可能是 < code>NSURLRequest 创建请求对象和
NSURLConnection
来实际从网络加载它。If you're talking about
-initWithContentsOfURL:
fromNSString
, it has been deprecated.But even if you are using it, it's a synchronous method - meaning your code will halt until the data has been loaded into the resulting
NSString
object:So, just to be clear: this is a bad practice for two reasons:
What you need is probably
NSURLRequest
to create your request object andNSURLConnection
to actually load it from the network.