StephenAshley.developer
StephenAshley.developer

Reputation: 1064

how to obtain NSURL from currentDirectoryPath

  NSURL *currentURL = [[NSURL alloc] 
    initWithString: [fileManager currentDirectoryPath]];

This call returns nil. How should I change it so that it returns a pointer to the NSURL for the current working directory?

Upvotes: 1

Views: 1566

Answers (3)

StephenAshley.developer
StephenAshley.developer

Reputation: 1064

Change initWithString: to initFileURLWithPath:.

Upvotes: 2

Daniel
Daniel

Reputation: 22405

Here is one way

 NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    int ind=0;
    NSString* destinationFilePath = [NSString stringWithFormat: @"%@/input%d.mp3", documentsDirectory,ind];

Upvotes: 0

Tom van der Woerdt
Tom van der Woerdt

Reputation: 29985

  • Documents directory: NSDocumentDirectory
  • Cache directory: NSCachesDirectory
  • Resource-specific directory: [NSBundle pathForResource:ofType:] (docs)

Upvotes: 0

Related Questions