2012-05-25 13 views
5

NSConnection का उपयोग करते हुए मुझे 'www.google.com' से कनेक्ट करते समय त्रुटि मिलती है।मुझे 'www.google.com' से कनेक्ट होने पर त्रुटि मिली NSConnection

मुझे कारण नहीं मिल रहा है। किसी भी तरह की सहायता को आभार समझेंगे।

NSString *urkString = @"www.google.com"; 
NSURL *url = [NSURL URLWithString:urkString]; 

NSURLRequest *request = [NSURLRequest requestWithURL:url 
              cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60]; 

_connection = [[NSURLConnection alloc]initWithRequest:request delegate:self]; 
if(_connection) 
{ 
    _receivedData = [[NSMutableData alloc] init]; 
} 
else 
{ 
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Cannot connect to the Web site." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil]; 

    [alertView show]; 
    [alertView release]; 
} 

लेकिन यह इस विधि को बुलाया गया। त्रुटि है:

Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x4c9feb0 {NSErrorFailingURLStringKey=www.google.com, NSErrorFailingURLKey=www.google.com, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x4c9fdf0 "unsupported URL"}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
{ 
    _endSystemDate = [self getSystemDate]; 
    _receivedData = nil; 
    _connection = nil; 
    _status = @"Completed"; 
} 

उत्तर

16

कोशिश NSString *urkString = @"http://www.google.com"; आप हर URL में URL योजना की आवश्यकता है। यानी http:// या https://

+0

realy.it के लिए धन्यवाद आपके प्रदत्त समाधान द्वारा हल किया गया है – Jonathan

संबंधित मुद्दे