gpt4 book ai didi

iphone - 在我的 iPhone 应用程序中将数据发布到服务器上

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:10:51 26 4
gpt4 key购买 nike

<分区>

我正在从 iPhone 应用程序向服务器发送数据,但是当我提交表单应用程序时崩溃。请检查代码并建议我提前告知。

-(IBAction)SAVE:(id)sender
{

NSString *post =[[NSString alloc] initWithFormat:@"amount=50&termid=1&state=%@&city=%@&post_title=%@&description=%@&post_price=10&post_location=asd&geo_latitude=%@&geo_longitude=%@&owner_name=%@&owner_email=abc@a.a&owner_phone=%@&post_tags=a&post_url=%@&coupon_code=a&current_userid=1&type=renew",txt4.text,txt5.text,txt6.text,latValue,longValue,txt7.text,txt8.text,txt9.text,txt10.text];

NSLog(@"String Posted:%@",post);
NSURL *url=[NSURL URLWithString:@"http://www.Example.com.mx/testing/publication.php?"];

NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",data);

con=[NSURLConnection connectionWithRequest:request delegate:self];
if(con){
responseData=[NSMutableData data];
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com