I was wondering if I could add the files to the app resources from an external url. As in suppose I see a url which has a nice image. Can I download that from the website and add it as a resource and use it locally for later use ? I am sure there is way But Need some guidance on how to approach the problem and The set of Classes that could be used with explanantion.
Thanks,
You can't change anything in your app bundle after it has been signed. If you did, you'd make the signature invalid, and the iPhone would refuse to run your app. Your best bet is to add the files to the Documents or tmp folder. There really isn't much of a reason to have stuff in your own bundle - is there a reason you have to have those images there?
Related
I have an app I'm designing that will allow for lots of PDF viewing. There are a lot of different languages available, and so if I were to include all of them in the app, it would be like 100+ mb in size which just won't fly.
So I'm thinking that I am going to put the pdf's on my server, and access them with a direct download link like this:
http://mysite.com/pdfs/thepdf.pdf
Which will return the exact pdf I want. So I'm wondering how I can go about accessing these resources as I download them on the fly?
I imagine I need to save the pdf's to the app resources folder? And then when a tableView row for the pdf is selected, I check if the pdf is in the resources folder (how do I do that?), and if not, pull it down off the server, and load it into my view?
I think I have an okay idea of what I need to do, just not very clear on the code to do it. Can anybody post the code for accessing the resources folder (if that's actually what I need to be doing), and maybe the code for how to check if something is in the resources folder?
Thanks!
Have you considered using a UIWebView to view the PDF instead of downloading and loading it yourself? UIWebView should take care of caching, so you won't have to worry about that.
Assuming that a UIWebView won't work, to download PDFs and see if they exist, you need to store it in the Documents folder. The resources folder cannot be altered after you submit your app to Apple, but the Documents folder in your app is completely fine. To access it, I would actually recommend ConciseKit, which can be found on GitHub. It gives you a helper method to access your app's document directory. The helper method is
[$ documentPath];
Then you can get the path for a file by doing
[[$ documentPath] stringByAppendingPathComponent:#"file.pdf"];
So that is how you get a path to a file, to check if it exists, you want to use NSFileManager.
[[NSFileManager defaultManager] fileExistsAtPath:#"path from above"];
I was able to save some files in the Documents folder on my app. How can I access them on the phonegap side of things with jqtouch/javascript/html. I want to do something like:
$('#intro').attr('src','../../Documents/logo.png');
But, apparently, it's not letting me go up all those directories outside of www.
How can I resolve this?
There is a bundle file reader plugin, but it seems to read the contents, not reference it.
https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/BundleFileReader
Not sure you can do what you are asking about. Perhaps you could use the PhoneGap File API to save the files somewhere within your www dir instead? Then they would be available via html/js.
Any Xcode project I create from scratch always contain either a sym link to the com.apple.AddressBook.plist file or to com.apple.PeoplePicker.plist in the folder:
Application Support/iPhone
Simulator/(SDK
Version)/Applications/(GUID)/Library/Preferences
Anyone know why this is and how do I go about the app never creating this?
It seems to get created after I run the app in the simulator and always comes back no matter what I do.
What purpose does this link serve?
The point of the symlink to com.apple.PeoplePicker.plist is to provide default sorting behavior for the PeoplePicker; when picking recipients for email message.
Reference: http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/QuickStart.html
For example, the website URL and other stuff that wants to be linked at runtime with the app? I find that info.plist is a good place for that. But maybe it is not allowed or causes trouble...?
I think it is fine, but the common practice is to create an extra plist for these custom stuff.
I want to bind my app to some file extension so when I receive an email with an attached file with the correct extension, clicking on it will launch my app and pass it the attached file.
Is it possible ? How ?
Thx
--G.
As iPhone applications are not allowed to share files on the file system, what you're looking for is not immediately possible (not with the published APIs that I know of, anyway). You might still have a couple of options though.
Either way you'll have to use a custom URL scheme, which is associated with your app, and paste that into your email. This URL might point to some external location, which your app can download the file from.
Or it might contain the actual file contents if it's fairly small. URLs are 'just text' (some restrictions apply), so you're free to put any data you want to in it, as long as it is URL-encoded.
You still need to get the URL into the email though, which might or might not be as easy as attaching a file.
It's not possible to simply associate a file extension with an application on the iPhone.
You could create a custom URL scheme that would launch your app, but probably that won't help you.
This is actually possible, I'm working on this exact same problem and this great tutorial has really helped me.