Sorting of files in Xcode

Discussion in 'iOS Programming' started by anmldr, Sep 16, 2008.

  1. macrumors member

    Joined:
    Jul 14, 2008
    #1
    I would like to alphabetically sort files that are in my Resources
    folder. They seem to be listed in the order that I added them to the
    project. This is a drug formulary and I am using UIWebView to view a
    couple of hundred drug sheets. How can I specify that Xcode show the
    files in alphabetical order and not in the order that I add them to
    the project...so that I can easily find the file to do some editing?

    TIA,
    Linda
     
  2. macrumors regular

    Joined:
    Jun 18, 2008
    #2
    Assuming you're reading those files into an NSArray or NSMutableArray look at the documentation for SortUsingSelector.
     
  3. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    You want to sort the listing of these files in the project window right?

    I don't think there is any built-in feature to do this. You're not the first person to ask. I think it would be possible to do this with applescript but it might take longer to write the script than just do it. Not sure if anyone has ever written such a script and posted it.

    The project file is an xml file and you could conceivably open the pbxproj file in a text editor and sort the relevant lines.
     
  4. thread starter macrumors member

    Joined:
    Jul 14, 2008
    #4
    That is correct. I solved the problem by deleting all of the files from the project window. But, I only deleted the references to these files. Then I went to the folder and (since they are sorted alphabetically in the folder) I re-added all of the files to the project and ta..da! Now they are in alphabetical order :)

    Not the ideal way of doing something like this since you could accidentally delete a file or forget to add a file back into the project.

    Thanks. This might be a good bug to submit to Apple or a suggested improvement for Xcode. I just thought that I was missing something.

    Thank you very much for your reply.
    Linda
     
  5. macrumors member

    Joined:
    Aug 30, 2006
    Location:
    US
    #5
  6. macrumors newbie

    Joined:
    Oct 21, 2008
    #6
    Xcode is a stupid IDE...

    Can't do simple things like sorting files. I have more than 100 files in the Resources folder and whenever I would like to rename/delete a file I'm wasting my time to find the file(s).
     
  7. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
  8. macrumors newbie

    Joined:
    Apr 12, 2009
    #8
    Xcode does indeed have built-in sorting. It's just not in the most intuitive of places.

    First, select the folder that you would like sorted.
    Now, go to the Edit menu in the main menu bar, and select Sort>By Name.
    Ta da! Sorted files.

    Unfortunately this doesn't keep it sorted, so you have to do it any time that you add files, but at least it is there.

    Edit:
    Extra tip that I forgot to mention: Because this functionality is in the menu, you're able to very easily bind a key to it. Personally I used the shortcut key for making a snapshot because I never use it; so all I have to do is highlight the folder I want sorted and press ctrl-apple-s and voila, it's sorted.
     
  9. macrumors newbie

    Joined:
    Jun 9, 2009
    #9
    Praise the lord!!! THANK YOU FOR THAT!
     

Share This Page