我使用下面的代码向web服务发送请求并获得响应,但在这里我一次两次得到请求,我不在哪里我错了,帮我从这个问题出来.提前致谢.
NSString *poststr=[NSString stringWithFormat:@"&cname=%@&conname=%@&email=%@",companynametxt.text,contactnametxt.text,contactEmailtxt.text];
NSLog(@"poststr %@",poststr);
NSData *postData = [poststr dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString: @"web servicess"]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
NSLog(@"DATA%@",theConnection);
[theConnection release];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *filenameStr=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"filenameStr %@",filenameStr);
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用Facebook和Twitter共享,在这里我想分享默认链接和文本而不显示共享窗口,我尝试了很多方法,但我仍然没有得到解决方案.
这是我的代码:
NSString *str_face=[NSString stringWithFormat:@"Another insta from Dealnabit just claimed now, Got yours now"];
SLComposeViewController *facebookPostVC =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook ];
[facebookPostVC addImage:[UIImage imageNamed:@"Default.png"]];
[facebookPostVC setInitialText:str_face];
[self presentViewController:facebookPostVC animated:YES completion:Nil];`
Run Code Online (Sandbox Code Playgroud)