ios - convert url into NSData -
i want upload voice recording on server.
my file url is:
file:///users/xantatech/library/developer/coresimulator/devices/77f4d768-1f04-4390-b60f-f1fe79388653/data/containers/data/application/87c457fa-1a9f-4ca9-a651-6a3d411a0b7e/documents/myaudio0.mp3
my code is:
nsdata* data = [nsdata datawithcontentsofurl:audiourl options:nsdatareadinguncached error:&error];
but data nil.
please try below code
nsstring *audiourlstring = @"file:///users/xantatech/library/developer/coresimulator/devices/77f4d768-1f04-4390-b60f-f1fe79388653/data/containers/data/application/87c457fa-1a9f-4ca9-a651-6a3d411a0b7e/documents/myaudio0.mp3"; nsstring *sendstr = [[audiourlstring absolutestring] stringbyreplacingoccurrencesofstring:@"file:///private" withstring:@""]; nsdata *data = [[[nsdata datawithcontentsoffile:sendstr]]];
good luck.....
Comments
Post a Comment