cocoamacosikimagebrowserviewikimagekit

IKImageBrowser loads files in reverse order?


I have an IKImageBrowser that loads images from the resources directory located inside the app. For some reason, the order it loads the file is in reverse, for example I have images 1-74, but they get loaded 74-1, any ideas?

Project is based off of the IKImageKit Demo.


Solution

  • Simple and 'ugly' solution:

    // File: ControllerBrowsing.m:
    // Function: - (void) addImagesFromDirectory:(NSString *) path
    
    // Find:
    for(i=0; i<n; i++)
    
    // Replace with:
    for(i=n-1; i>=0; i--)
    

    Good solution (one of the many possibilities):

    1. Create a new NSMutableArray.
    2. Loop through the NSArray that contains the files.
    3. Add the paths to the NSMutableArray.
    4. Sort the NSMutableArray the way you like.
    5. Loop trough the NSMutableArray and add the items.