ios - NSUrl from NSString returns null -
i want parse location of documents directory nsurl
nsstring
have.
when console nslog(stringurl)
i get: "/var/mobile/applications/2b35d06d-6e4a-40f2-833e-28463a946834/library/application support/myappdirectory" output.
but when do
nsurl* url = [nsurl urlwithstring:stringurl];
and nslog(url) (null) output.
what doing wrong here?
from apple documentation "an nsurl object initialized urlstring. if url string malformed or nil, returns nil." stringurl isn't correct formed url. reference: https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/classes/nsurl_class/reference/reference.html#//apple_ref/occ/clm/nsurl/urlwithstring:
what want use is: fileurlwithpath: isdirectory:
instead.
nsurl *url = [nsurl fileurlwithstring:[stringurl stringbyaddingpercentescapesusingencoding:nsutf8stringencoding] isdirectory:yes]; nslog(@"%@", url);
Comments
Post a Comment