NSString *myString = @"1994";
NSString *post =[[NSString alloc] initWithFormat:@"data=%@",myString];
NSURL *url=[NSURL URLWithString:@"http://nyxmyx.com/Kinkey/KinkeyPHP/lastid2.php/?data=%@",myString];
NSLog(@"URL%@",url);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSLog(@"postDATA%@",postData);
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"postLENGTH%@",postLength);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSError *error1 = [[NSError alloc] init];
NSHTTPURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error1];
NSString *string;
if ([response statusCode] >=200 && [response statusCode] <300)
{
string = [[NSString alloc] initWithData:urlData encoding:NSMacOSRomanStringEncoding];
UIAlertView *alert1=[[UIAlertView alloc]initWithTitle:@"alert1" message:string delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert1 show];
}
我是目标 c 的新手。当我发送带有参数的 NSURL 时,它会给出错误,因为“参数太多需要 1 有 2”如何用一个参数更改我的 url?