使用此代码而不是提供字符串输出的代码,然后您必须格式化该字符串以获得不期望的输出。
NSString *post =@"";
NSURL *url=[NSURL URLWithString:@"http://nyxmyx.com/Kinkey/KinkeyPHP/lastidretrieve.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 setHTTPBody:postData];
NSError *error = [[NSError alloc] init];
NSHTTPURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if ([response statusCode] >=200 && [response statusCode] <300)
{
//NSData *data = [responseData resourceDataUsingCache:YES];
NSString *string = [[NSString alloc] initWithData:urlData encoding:NSMacOSRomanStringEncoding];
NSLog(@"responseData-%@",string);
}
输出将是这样的。
responseData-1995<br />prabu<br />1231231233<br />antab<br />8080808080<br />1360738531881.jpg<br />No
更新
如果您想在 URL 中添加参数而不是将帖子字符串更改为此。
NSString *post =[[NSString alloc] initWithFormat:@"yourArg=%@",yourArg];