Does -dataWithContentsOfURL: of NSData work in a background thread?

前端 未结 7 1421
南笙
南笙 2020-12-30 05:39

Does -dataWithContentsOfURL: of NSData work in a background thread?

相关标签:
7条回答
  • 2020-12-30 06:44

    I'm guessing this has changed a bit over the years. But, these days,

    NSURLRequest* request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse* response, NSData* data, NSError* error) {
    }];
    

    will give you an async network call.

    0 讨论(0)
提交回复
热议问题