简体   繁体   中英

Multiple simultaneous NSConnections for web query

When using async download methods and delegates, is it possible to start multiple simultaneous nsconnections and handle them separately as each query completes? Or, will the system not automatically distinguish between them as your delegates receive pieces from each query? In which case, what would be a good approach to identify each connection uniquely as it enters through the delegates?

The system won't automatically distinguish the NSURLConnections , instead, each delegate methods called is precising the concerned connection.

For example: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;

the connection is connection . This way you can set several NSURLConnection s and react accordingly.

I personnaly set NSURLConnection objects as ivars and test for equality in delegate methods, because using delegate, you will need to access the data containers from different methods.

You will find more information in the excellent URL Loading System Programming Guide from Apple.

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