Get a list of images in the project in iOS? - 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

Related

Create a plist outside Xcode?

In our app we have lots of photos that we need to read while using the app, we have to also orgenize them into groups/categories.
this option is to make a plist with their names, and just put them into the app and read the plist.
create folders inside the app, order them inside, and read the specific folder.
Option 2 took me days and I couldn't even make it work reliably, and it also seems not the right way to work for some reason.
Option 1, the problem is that if you have 100 files you have to edit your plist every time again for a new file you add.
Is there a way to make option 1 outside of xcode so I can put all files in a folder on my mac, get their plist, and put this plist inside Xcode ?
What's the right way to achieve this ?
plist is just a simple XML file. You can create the plist file and add to xcode as any normal file to the bundle and read it.
macOS comes with two command-line tools for manipulating plists:
/usr/bin/plutil can convert a plist between formats. You might like this because you could write your photo catalog in JSON using whatever tools you like, then convert it to a plist. Of course, then you could just use JSON directly in your app…
/usr/libexec/PlistBuddy (note that /usr/libexec is not normally in one's PATH) can modify a plist in place, adding, removing, or changing entries.
Both of these tools have man pages (man plutil, man PlistBuddy) and substantial built-in help (plutil -h, /usr/libexec/PlistBuddy -h).
First, you're making a false assumption. There is no need to use a plist file here. An ordinary text file listing the names will do just fine, and you can just make up your own format to dictate groups and suchlike. And that sort of file is trivially easy to maintain.
Second, your rather confused claim that "Option 2 took me days and I couldn't even make it work reliably, and it also seems not the right way to work for some reason" is just a cop-out. Folder references are not a difficult thing to use (you can configure them in the Finder, which is as simple as you can get), they do work just fine, and they are a perfectly reasonable solution here.

How can I sort iMessage images by name?

When I add images to Sticker Pack, they added unsorted. I can sort them manually, one-by-one, but how to sort all of them by name for one time?
Just found the solution.
Correct Way: (Important note - sort files in Finder correctly)
Wrong way

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

Best practice for Loading many files to local Documents Directory on iPad

I'm about to write an app for iPad2 to make website offline available.
Several Publications (consisting of one HTML, one Javascript an many PNG Files) need to be downloaded to the iPad for offline Viewing.
Is there a good unzip-class for iOS so that i could download a zip from server and unpack it to a subdirectory in Documents Folder?
http://code.google.com/p/objective-zip/ looks like the right code for your needs.
If compression doesn't matter, the untar algorithm is pretty easy to implement. Either you keep it as plain C, or you adapt it to objective-C.
Reference: http://code.google.com/p/libarchive/source/browse/trunk/contrib/untar.c?r=1143

Resources