Add downloaded resources (images) to Bundle? - ios

I am developing an application which is a kind of contact list. This list is updated each times the applications starts.
Each contact in the list has its own photo. A part of this list is common for every user of this application. For this part, I already have all the needed pics and I inlude them in the bundle/archive (which will be sent to Apple).
The pics of the new contacts (added during the lifetime of the app) are downloaded from a remote server (using ASIHTTPRequest). But I don't know how to handle these downloaded pics easily.
I am looking for a way to add these downloaded pics to the main bundle so I can call them using :
+ (UIImage *)imageNamed:(NSString *)name
Do you have any idea of the good practices for this kind of things ?
If new resources can't be added to the main bundle, what are your recommendations ?
Thanks again for your help !
kheraud

You can only add files to your App's Documents directory. The main bundle can't be modified after your App has been released. Read the documentation on how to write to the directory.
Edit_: This should help you to get started http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html%23//apple_ref/doc/uid/TP40007072-CH4-SW6

I'm doing a similar thing for an app, and in the past I've used a couple of different Categories for UIImage.
For the current version I'm looking at https://github.com/rs/SDWebImage but I had really good luck using this one in a previous version https://github.com/jaanus/UIImageViewCached. For my purpose, I was downloading images from a URL and then caching them for use in a TableView.
HTH

Related

iOS - Can users access App Bundle Contents (specifically the Bundle Resources)

I'm relatively new to iOS development. My question is quite simple but there seems to be a lot of un-complete answers out there.
For example, I have a few pictures that are used in my app and I don't want the users to have access to these pictures at all (due to copyright). I've included these into the "Bundle Resources" along with the "Image.cxassets" and other .xib files.
Will the user ever be able to access the pictures? (I understand that the user can't access the Library folder but it seems to be a pain to copy the pictures into the Library folder at app first launch.)
thanks ahead for answering.
I didn't understand what exactly you're asking, but for users to access your app bundle contents the file sharing for iTunes option should be set in .plist. See in the reference
Although you may put dot before file ".image.jpg" to make it hidden but it sounds like temporary solution.

Providing initial files in /Documents/ folder in an iOS app

Strangely I can't find a lot of information on this.
I am making an application that downloads images, they are downloaded and saved into my apps /Documents/ folder. To avoid an initial huge download I want to ship the app with ~100 images already "downloaded" into the folder.
How can I do this?
They have to go into your Resources bundle. You can then copy them into Documents on first launch. Yes, this means they take twice the space; if you can compress the ones in Resources effectively, I would.
An ideal answer is to have your loading routine be willing to look in both Documents and your Resources bundle and merge the results. I don't believe any built-in controllers will do this for you, however.

Loading External Bundle Files allowed?

We are trying to load external NSBundle files remotely using a technique similar to below
loading NSBundle files on iOS
Does anyone know whether apple allow you to do this?
I assume as long as you don't change the functionality it is allowed?
Thanks for all your help
You should ask Apple to be sure, but probably no.
The bundle can contain image / data resources but also code, and there is a restriction guideline against running code that wasn't in the app when it was reviewed. If you're just loading image / data resources then you'll probably be fine. Code resources, you might get through review but would likely be pulled if found out.

Putting App Resources in Document Directory in iOS

My app have too much dynamic app resources like images, html+css and xml or json files..that can be updated, So I cannot put these resources in app bundle it will not get updated once on app store i need to have it updated there...secondly i also cannot put these resources on server where I can request the content from server every time i need it...
So my question is that is good to store data locally in document directory??? how does apple app review team will react to it? I have heard that there is an iCloud problem while putting data in document directory is it right?
So where to store data of iOS application locally on device?
Thanks in Advance.... Looking for some good solid answer!
This kind of data should be copied to ~/Library/Application Support. See the File System Programming Guide for full details on where everything goes and how it will be treated.
You may want to consider having the initial assets you are referring to be resident in your application bundle. And then when you have updated versions, save them in your Documents directory (or any legal path you want).
The reason for this is for failover, in case there is a problem, it allows you to revert back. When you are dynamically loading content, you have to factor in you can encounter various problems during a download such as corrupt data or even a dependency not being downloaded yet.
FWIW, I implemented this for a game that supported dynamic loading of content. The bundle had the original assets. There was a temp download directory. When data was validated, it was moved to a locale where it was consumable. On app start, the first step was to just copy the data from the bundle to the consumable directory. While it seems perhaps wasteful and several steps, it worked surprising well and most would not even know this sort of thing was happening.

Downloading and saving files with AIR for iOs

For a project we need to download and save pdf files on an IPAD device for offline use through an AIR for iOs application.
After a lot of searching I haven't found much information on this subject. My question is, can it be done, and if so, can you provide us with some pointers to lead us in the right direction.
Thanks for your time!
Sure, first you check if you can access the web - can use a class like air.net.URLMonitor, if you can you can set up a URLStream instance.
You get data while its downloading the file using the progress event, write that out to a File instance using the FileStream class.
To display the PDF file you can use a StageWebView or HTMLLoader.

Resources