Get NSString from NSURL

I am trying to get NSString from NSURL using this method:

 NSString *tmp2 = [item.path absoluteString]; 

Unfortunately, I get instead of NSURL:

 <CFURL 0x173c50 [0x3f1359f8]>{type = 0, string = /var/mobile/Applications/A30FD2E4-A273-4522-AFD5-A981EFD3C2AA/Documents/*** *** - *** ***.***, encoding = 134217984, base = (null)} 

I get:

 file://localhost/var/mobile/Applications/A30FD2E4-A273-4522-AFD5-A981EFD3C2AA/Documents/***%20***%20-%20***%20***.*** 

any idea why?

+8
objective-c iphone
source share
1 answer

NSURL documentation clearly states that absoluteString returns an NSString, just like your code above. This is a string representation of the absolute path, so what you get is what you should get.

However, looking at the documentation, you can also use path , relativePath or relativeString to get a string representation of the URL in other formats (absolute or relative paths that either do or do not conform to RFC 1808 (now obsolete percent encoding ).

+20
source share

All Articles