I have the following code:
+(NSURL*) getRecordingDirectory {
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
NSURL* url = [[NSURL alloc] initWithString:documentsDirectory]; //<-- nil
return url;
}
The line NSURL* url = [[NSURL alloc] initWithString:documentsDirectory];
Doesn't seem to work. url
remains nil
after the line.
You need to use a file URL to get the location of a resource on the file system.
[NSURL fileURLWithPath: documentsDirectory]
You can also use NSFileManager
to get the same URL.
NSArray *arr = [[NSFileManager defaultManager] URLsForDirectory: NSDocumentDirectory inDomains: NSUserDomainMask];
NSURL *documentsUrl = [arr firstObject];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With