简体   繁体   中英

What is the correct way to use NSURLConnection return data?

What is the difference between the following two code snippets? When I use the first snippet, the requests goes through but data holds 0 bytes, where as in the second case I do get the data. I know the second snippet works but why? I am using synchronous call here.

This one returns 0 bytes of data...

NSData *data  = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];

This one returns correct data...

NSData *data ;
data = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];

There's no difference between these two statements. Are you absolutely sure that there's no other modification?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM