Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 921
YosiFZ Avatar asked Jan 04 '12 16:01

YosiFZ


Video Answer


1 Answers

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).

like image 68
David Rönnqvist Avatar answered Sep 19 '22 06:09

David Rönnqvist