第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在IOS上發(fā)送HTTP POST請(qǐng)求

在IOS上發(fā)送HTTP POST請(qǐng)求

有只小跳蛙 2019-07-06 15:14:50
在IOS上發(fā)送HTTP POST請(qǐng)求我正在嘗試用我正在開(kāi)發(fā)的iOS應(yīng)用程序發(fā)送HTTPPost,但是推送永遠(yuǎn)不會(huì)到達(dá)服務(wù)器,盡管我確實(shí)獲得了響應(yīng)代碼200(來(lái)自u(píng)rlConnection)。我從來(lái)沒(méi)有得到服務(wù)器的響應(yīng),服務(wù)器也沒(méi)有檢測(cè)到我的帖子(服務(wù)器確實(shí)檢測(cè)到來(lái)自Android的帖子)我確實(shí)使用ARC,但已經(jīng)將PD和urlConnection設(shè)置為強(qiáng)連接。這是我發(fā)送請(qǐng)求的代碼 NSMutableURLRequest *request = [[NSMutableURLRequest alloc]                                       initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",dk.baseURL,@"daantest"]]];     [request setHTTPMethod:@"POST"];     [request setValue:@"text/xml"    forHTTPHeaderField:@"Content-type"];     NSString *sendString = @"<data><item>Item 1</item><item>Item 2</item></data>";     [request setValue:[NSString stringWithFormat:@"%d", [sendString length]] forHTTPHeaderField:@"Content-length"];     [request setHTTPBody:[sendString dataUsingEncoding:NSUTF8StringEncoding]];     PushDelegate *pushd = [[PushDelegate alloc] init];     pd = pushd;     urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:pd];     [urlConnection start];這是我的委托代碼#import "PushDelegate.h"@implementation PushDelegate@synthesize data;-(id) init{     if(self = [super init])     {         data = [[NSMutableData alloc]init];         [data setLength:0];     }     return self;}- (void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:     (long long)totalBytesWritten{     NSLog(@"didwriteData push");}- (void)connectionDidResumeDownloading:(NSURLConnection *)connection totalBytesWritten:(long long)     totalBytesWritten expectedTotalBytes:(long long)expectedTotalBytes{     NSLog(@"connectionDidResumeDownloading push");}- (void)connectionDidFinishDownloading:(NSURLConnection *)connection destination     URL:(NSURL *)destinationURL{     NSLog(@"didfinish push @push %@",data);}- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWri     tten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{
查看完整描述

3 回答

?
胡子哥哥

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊

我不太確定為什么,但只要我注釋掉以下方法,它就會(huì)奏效:

connectionDidFinishDownloading:destinationURL:

此外,我認(rèn)為您不需要來(lái)自NSUrlConnectionDownloadDelegate協(xié)議的方法,只需要來(lái)自NSURLConnectionDataDelegate的方法,除非您需要一些下載信息。


查看完整回答
反對(duì) 回復(fù) 2019-07-06
  • 3 回答
  • 0 關(guān)注
  • 2741 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)