objective c - NSURL with string giving null value -


below have

nsstring *foofile = @"/users/alkandari/library/application support/iphone simulator/6.1/applications/8c445026-6387-4e40-b5a3-d1a1680666d6/documents/projacsbodfiles/file_5_21.pdf" nsurl *url; if (fileexists) {     url = [nsurl urlwithstring:foofile];     nslog(@"taking local file 1 ... %@==%@", url, foofile); } else {      url=[nsurl urlwithstring:address];     nslog(@"taking internet file 1... %@", url); } 

when execute, log below

taking local file 1 ... (null)==/users/alkandari/library/application support/iphone simulator/6.1/applications/8c445026-6387-4e40-b5a3-d1a1680666d6/documents/projacsbodfiles/file_5_21.pdf 

i don't understand why getting url null. because of not able open file.

any idea why getting url null above?

you need use fileurlwithpath path localfile system:

nsstring *foofile = @"/users/alkandari/library/application support/iphone simulator/6.1/applications/8c445026-6387-4e40-b5a3-d1a1680666d6/documents/projacsbodfiles/file_5_21.pdf" nsurl *url; if (fileexists) {     url = [nsurl fileurlwithpath:foofile];     nslog(@"taking local file 1 ... %@==%@", url, foofile); } else { ... } 

Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -