Create asset catalogue programmatically in swift - ios

Am fairly new to swift (in fact who isn't, but am new to iOS development too) and currently working on an app which involves good number of images. I could categorise the images and add it in asset catalogues for the initial app. However, there would be some options for the user to download the images also. In such case, i would like to add the images to an asset or create a new asset catalogue programmatically. I am not sure whether its a good idea or is there any other better idea to store the images? Googled for some suggestions , but I couldn't get any.. Any help / suggestions would be much appreciated..

Related

PDF image for iOS Assets

we can add image as pdf in ios assets for application.But i'm confusing that which approach is good for application.
Png file direct drag and drop to Assets
or use image as PDF
i have follows links
https://icons8.com/articles/how-to-use-vectors-in-xcode-7/
and https://bjango.com/articles/idontusepdfs/
but not able to decide which one is better solution for assets.
i know how to works with pdf asset but cannot decide which method is better from development point of view.
Thanks in advance.
If your artwork has complex gradients, generate the PNGs yourself. Otherwise, use PDFs. That's how I read it.
Personally, I have the luxury of working with a designer who just gives me assets at all the required sizes. On another project, Sketch was used which can auto-generate PNGs from a script as part of the build process. So I've never actually used PDFs.

Image Localisation using images in Assets

I found the following issue exists for a long time, And I also find there are many solutions available, But this thread is to get recommended way to do it.
Issue:
We cannot able to localise the images directly from assets folder but we can able to localise the images which we place it in File inspector as shown in the image.
I need to know the answers for the following questions:
- Why we don't have localisation for images in Assets folder ?
- What is the Apple recommended way to localise images ?
Please answer the questions. And if you have any link recommended by Apple please add that with your answers.
Note:
- Its not a duplicate question, am asking this since we know we cannot able to extract / reverse engineer to get the images used in the iOS application assets. But thats not the case with the images placed in the file inspector which can be extracted. So this question is all about Apple's recommended way to approach image localisation and not possible solution.
There is not any correct way to localise the xcassets file directly,
but still you can localize the name of the asset to get using your localizable.strings file.
For example:- you want to put any main image at home screen for different different region so you can save that image to xcassets to using their localise name and you can fetch that image like this.
UIImage *img = [UIImage imageNamed:NSLocalizedString(#"Main_image", nil)];
and here is the link from apple that spacify how you can localize the image. LINK

Adding image sets to images.xcassets catalog programmatically in iOS?

I've searched high and low on stackoverflow and google for an answer to this question. Perhaps it's not possible, or I may need to devise a different method to do this.
In our iOS app we have a whole bunch of image sets in images.xcassets. But we're moving to a more dynamic environment where we'll be downloading image sets instead.
I'd like to try and stick with the convention of having everything in the images.xcassets folder. Except as said, I want to dynamically create the image sets based on the data we retrieve from our server. Is this possible?
So there is a way to do this, but it's iOS 8.0 and above. Unfortunately, we're supporting 7 and above so I can't use it.
But for anyone else who's interested, you can use the UIImageAsset class to do what you need to do when you want to create a container for your images to encapsulate different resolutions, as the images.xcassets container currently does.
UIImageAsset docs
This answer gives a good overview of the XCAssets folder at runtime: Can I access an xcassets directory on the filesystem? - it looks like it's the wrong way of going about things.
I believe it is recommended that you use the temp or document folders, depending on the how long you wish to keep these images (https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html).

SimpleCmsImage.save will not save a thumbnail image

I have a Ruby on Rails web application that uses the Simple CMS plug-in to upload images to the app.
I've used this before. In fact, my current web application is a clone of an original application that works perfectly.
With the new app, the image itself uploads okay, but - unlike the original app - it does not automatically generate a thumbnail image.
I've isolated this down to the point where SimpleCmsImage.save is called. In the original app, this automatically does two insertions into the simple_cms_image table - one for the image itself; and one for the automatically-generated thumbnail image.
In the new app, there is only one insertion for the image, none for the thumbnail.
Does anyone have any suggestions? I'm at my wit's end to figure this one out?
Thanks in advance,
Tim

Add downloaded resources (images) to Bundle?

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

Resources