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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

有只小跳蛙 2019-07-06 15:14:50
在IOS上發(fā)送HTTP POST請求我正在嘗試用我正在開發(fā)的iOS應(yīng)用程序發(fā)送HTTPPost,但是推送永遠(yuǎn)不會到達(dá)服務(wù)器,盡管我確實(shí)獲得了響應(yīng)代碼200(來自urlConnection)。我從來沒有得到服務(wù)器的響應(yīng),服務(wù)器也沒有檢測到我的帖子(服務(wù)器確實(shí)檢測到來自Android的帖子)我確實(shí)使用ARC,但已經(jīng)將PD和urlConnection設(shè)置為強(qiáng)連接。這是我發(fā)送請求的代碼 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個贊

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

connectionDidFinishDownloading:destinationURL:

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


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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