我正在從iPhone應用程序發送數據到服務器,但是當我提交表單應用程序crash.Please檢查代碼,並建議我提前致謝。在我的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=%@&[email protected]&owner_phone=%@&post_tags=a&post_url=%@&coupon_code=a¤t_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];
}
}
其中是要檢查的代碼? –
在這裏添加代碼來檢查 – manujmv
您可以發佈代碼嗎? – SRI