Home / IOS Development / NSURLSessionDataTask takes a long time, how do I take data faster? : iOSProgramming

NSURLSessionDataTask takes a long time, how do I take data faster? : iOSProgramming



I use NSURLSessionDataTask dataTaskWithURL to retrieve the data from a .mp4 file and save it locally. A simple 5-minute video takes 10 minutes to get all the data. I have a good connection and a good network. How do I increase the speed? Here is my code

NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
            NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]];
            NSURLSessionDataTask *dataTask = [defaultSession dataTaskWithURL:[NSURL URLWithString:stringURL]];

            [dataTask resume];

And I use this method to get the data when it comes in

- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {
    
    [_dataToDownload appendData:data];

}

Source link