Get array of all images in asset catalog folder - ios

In iOS is it possible to get an array of images (or image names) that are inside a folder of an asset catalog?
If so, how?
I'm not really sure why there is a down vote on this. I really have no idea where to start.
My alternative is to create a plist of all the files in the folders but it just seems redundant.
I can't add any code because what would I add?
Would love to get feedback on why there is a down vote though.

Of course, you can read the directories that your app owns, you can create/remove..
You can start reading NSFileManager documentation at
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html
You can download the related source code as examples and see how this is done.
I hope this helps.

Related

How to fetch all images from a remote directory in Swift?

I have set up a server with a subdirectory e.g. /html/images and I would like to download all the images (when possible ordered by the date they were added to the directory) without knowing the names of the files.
How can this be done? What could be other solutions if this isn't possible?
I have searched for a solution but the already answered questions are pretty old now. e.g. Get all folders of URL
There is no way to do that on your IOS app.
The server should give you an API that provides you an array of images.

Get a list of images in the project in iOS?

I imported a lot of images into my app. I could use imageNamed: for each item but it is very hard to do manually (~50 images). Can I somehow get a list of them? It is just for testing purposes, so private api is acceptable too.
Or will it be easier for me to rename them to something like 1.jpg, 2.jpg and etc.
the best way for you is rename you file to ( 1,2,3 xxx )
but there is a tool that help you to see you picture from app bundle during your coding
KSImageNamed

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).

(Rails) Uploading Directories

I need to upload multiple files on my website.
But I need not just a form for uploading multiple files, I need to upload whole directories.
How's this possible for the minimalist?
Yours, Joern.
According to my somewhat limited knowledge this is not possible, only file transfer is possible, not directories.
Here are some workarounds, based on discussion on Velocity Reviews and another discussion:
upload a zip, which you unzip at the server side
upload directories over ftp (web page can be a front end to this)
upload files one by one
I would go either for zip or ftp. Note: someone might have produced a gem that enables uploading directories (I know nothing of such thing, but I will be happy to find out, if there is).
Adding another option to the list provided by Sorrow:
upload via REST/JSON
OK, this is a partial solution, but it does give you the opportunity to write a script that reads your directory and POSTS to your website.

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