Vote count:
0
I am trying to read some web sites using synchronous request. But following code returns no data(length is zero) without error.
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://ift.tt/1iSQGXB"] cachePolicy:1 timeoutInterval:20];
//NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://ift.tt/OzJOV8"] cachePolicy:1 timeoutInterval:20];
NSURLResponse *response=nil;
NSError *error=nil;
NSData *data=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if ( data == nil ) {
.....;
}
NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
if ( str == nil ) {
.....;
}
NSLog(@"LENGTH = %d",[str length]);
But commented line in above code works well.(only URL is different) I am working with Xcode 6.
asked 32 secs ago
NSURLConnection sendSynchronousRequest: returns NO data without error
Aucun commentaire:
Enregistrer un commentaire