YosiFZ
YosiFZ

Reputation: 7900

Get NSString From NSURL

I try to get NSString from NSURL with this method:

NSString *tmp2 = [item.path absoluteString];

Unfortunately I get instead of the 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?

Upvotes: 10

Views: 12921

Answers (1)

David R&#246;nnqvist
David R&#246;nnqvist

Reputation: 56645

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

However, looking at the documentation you could 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 (a now obsolete percent encoding).

Upvotes: 21

Related Questions