Pergunta

I have an audio file (binary) file which is stored in a file in document folder, I want to read the data from file and upload to server using a php script, my question is whats the best way to read this file form the disk ?

Foi útil?

Solução

You can simply use

NSData *fileData = [[NSData alloc] initWithContentsOfFile:@"My File Path"];

to read the contents of the file. But if the file is .5 to 2 mb, sent the read operation to a thread using GCD, NSOperationQueue or Similar.

If you are targeting iOS7 and above you could try the new NSURLSession

https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/Introduction/Introduction.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top