Posted at

Conversion between NSURL and filePath

More than 5 years have passed since last update.

NSURLとfilePathの変換をしたい場合。

参考


File Path -> NSURL

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:@"/dir/file.txt"];  

// or
NSURL *fileURL = [NSURL fileURLWithPath:@"/dir/file.txt"];


NSURL -> filePath

NSString *filePath= [fileURL absoluteString]; 

 // or
NSString *filePath= [fileURL path];