NSURLConnection委托方法 [英] NSURLConnection delegate method

查看:123
本文介绍了NSURLConnection委托方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难找到NSURLConnection委托方法实现的任何示例。

I am having a hard time to find any examples for NSURLConnection delegate method implementations.

我想通过点击按钮发送带有HTTP帖子的数据。不确定如何制作提交屏幕并提交。 (我知道如何使用微调器并将使用它们)

I want to send data with a HTTP post with a button click. Not sure how to make a "submitting" screen and "submitted". (I know how to use spinner and will use them)

我在botton点击操作下使用此代码,但无法使用任何委托内容。不知道如何使用我当前的设置来实现它们。

I am using this code under a botton click action, but unable to use any delegate stuff. Not sure how to implement them with my current set up.

NSMutableURLRequest *request = 
    [[NSMutableURLRequest alloc] initWithURL:
     [NSURL URLWithString:@"http://myURL.com"]];

    [request setHTTPMethod:@"POST"];

    NSString *postString = [wait stringByAppendingString:co];

    [request setValue:[NSString 
                       stringWithFormat:@"%d", [postString length]] 
   forHTTPHeaderField:@"Content-length"];



    [request setHTTPBody:[postString 
                          dataUsingEncoding:NSUTF8StringEncoding]];

    //[[NSURLConnection alloc] initWithRequest:request delegate:self];
    [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];


    [SVProgressHUD dismissWithSuccess:@"Submission Successful"];


推荐答案

您需要使用新的NSURLConnectionDataDelegate协议。

You need to use the new NSURLConnectionDataDelegate protocol.

我在这里找到了一些例子:

I found some exemples here:

HTTP:/ /blog.kemalkocabiyik.com/index.php/2012/02/fetching-data-with-getpost-methods-by-using-nsurlconnection/

如果你能阅读葡萄牙语: http://www.quaddro.com.br/blog/desenvolvimento-ios/baixando-conteudo-com-nsurlconnection-e-nsurlconnectiondatadelegate-no-ios

And if you can read portuguese: http://www.quaddro.com.br/blog/desenvolvimento-ios/baixando-conteudo-com-nsurlconnection-e-nsurlconnectiondatadelegate-no-ios

这篇关于NSURLConnection委托方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆