我想使用下面的代碼'觸發'的網址。 Web服務器不返回任何數據。但NSURLConnection正在建立中。NSUrlRequest不工作目標C
NSString *serverAddressTest = @"http://domain.com";
NSString *fullWebAddress = [NSString stringWithFormat:@"%@?CustomerName=%@&ContactNo=%@&Products=%@",serverAddressTest,customer,contactnumber,allProductsInString];
NSURL *url = [NSURL URLWithString:fullWebAddress];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:url];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
NSMutableData *webData = [NSMutableData data];
NSLog(@"%@",webData);
}
else {
NSMutableData *webData = [NSMutableData data];
NSLog(@"%@",webData);
}
很可能你應該對url進行編碼 – Andrea
錯誤委託方法是否被調用? – Wain
如果(連接){NSMutableData * webData = [NSMutableData data];調試失敗,則調試中將不會發生錯誤。 NSLog(@「%@」,webData); } – user3579247