NimbleKit - fast iOS app development

Easy way to check if file exists in bundle?

Ask questions and share your skills here

Easy way to check if file exists in bundle?

Postby floz » Fri Dec 09, 2011 7:04 pm

Hi there,

Is there an elegant way (in particular not using jQuery etc) of checking whether a file exists in the bundle?

I have a database and it points to image files (jpegs), but I need a way of double checking that the image files are indeed in the app bundle, so that I can handle the case better when they're not . . .

Cheers, Floz
User avatar
floz
NimbleKit Guru
 
Posts: 261
Joined: Sat Feb 05, 2011 2:07 pm
Location: Newcastle, Australia

Re: Easy way to check if file exists in bundle?

Postby ryubr » Fri Dec 09, 2011 8:00 pm

I think the NKFile can handle this for you on the open method returns if it was able to open the file accoding the docs:
open(fileName)
Opens file with given filename for reading, should be just name and file extension,
returned value is either “1” or “0” identifying if file was opened.


:-)
ryubr
NimbleKit Expert
 
Posts: 445
Joined: Fri Jun 19, 2009 5:36 am

Re: Easy way to check if file exists in bundle?

Postby floz » Fri Dec 09, 2011 8:08 pm

I looked at that, but it also recommends against using NKFile. So I was looking for a different way ...
User avatar
floz
NimbleKit Guru
 
Posts: 261
Joined: Sat Feb 05, 2011 2:07 pm
Location: Newcastle, Australia

Re: Easy way to check if file exists in bundle?

Postby ryubr » Fri Dec 09, 2011 8:42 pm

So the best thing is to use OBJ-C mix to check for files, just adapt the NKBlueprint method :-)
ryubr
NimbleKit Expert
 
Posts: 445
Joined: Fri Jun 19, 2009 5:36 am

Re: Easy way to check if file exists in bundle?

Postby ryubr » Fri Dec 09, 2011 8:55 pm

ryubr
NimbleKit Expert
 
Posts: 445
Joined: Fri Jun 19, 2009 5:36 am

Re: Easy way to check if file exists in bundle?

Postby floz » Fri Dec 09, 2011 9:11 pm

I actually wrote a whole file toolkit a while back (it's somewhere in the forums here), I know that I could use that. But again, I was hoping for a three line JavaScript method. But if I have to bring out the big guns, fine.
User avatar
floz
NimbleKit Guru
 
Posts: 261
Joined: Sat Feb 05, 2011 2:07 pm
Location: Newcastle, Australia


Return to How To...

Who is online

Users browsing this forum: No registered users and 1 guest