检查sendsynchronousrequest是否成功
我只是想知道这是否是检查 sendsynchronousrequest 是否成功的正确方法:
NSData* returnData = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:nil];
if(returnData == nil)
{
//code showing an alertView for example
}
else
{
//do somthing else
}
提前感谢您的反馈
肖恩
i just wanted to know if this is the right way to check if a sendsynchronousrequest was successful:
NSData* returnData = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:nil];
if(returnData == nil)
{
//code showing an alertView for example
}
else
{
//do somthing else
}
thanks in advance for your feedback
sean
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想你想为你的错误传递一些东西:
但我可能是错的,只是快速浏览了一下。
我确实看到了这篇文章..我认为他在问类似的事情:
http:// Discuss.apple.com/thread.jspa?threadID=1647649
I think you want to pass something in for your error:
But I could be wrong, just quickly glanced at it.
I did see this post though.. I think he's asking a similar thing:
http://discussions.apple.com/thread.jspa?threadID=1647649
如果您使用 HTTP,那么您还可以检查状态代码。例如:
If you're working with HTTP, then you might also check the status code. For example:
正确的方法是定义一个错误变量,将其设置为 nil 并在 nsurlconnection 中使用其引用,以便在该引用内存位置返回错误。检查内存是否为 nil,如果 nil 成功,如果有一些有效内存,则为错误
The correct way is to define an error variable set it nil and use its reference in nsurlconnection such that the error is returned in that reference memory position .Check the memory is nil and if nil success,if it has some valid memory it is error