1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Read/Write To Package Contents?

Discussion in 'Mac Programming' started by Darkroom, Apr 15, 2009.

  1. Guest

    Darkroom

    #1
    is it not possible to read/write to "Package Contents" paths (or whatever they're called)? i'd like to write a program that writes a file to the applications resources folder. using XCode as an example:

    Code:
    NSString *textFile = @"/Developer/Applications/Xcode/Contents/Resources/myTextFile.txt";
    
     
  2. macrumors 6502a

    #2
    It sounds like:
    Code:
    [[NSBundle mainBundle] resourcePath]
    
    would get you what you want, but I am going to really, really recommend against doing this if you are going to write to that location. A much better target would be to write out to folders in ~/Library/Cache or ~/Library/Application Support. Or you could write out to the a folder in the users /var/folders folder (use confstr() with _CS_DARWIN_USER_TEMP_DIR, to get that). But I would caution against that last one, as it is not commonly known to users that that exists, and filling up their drive in a spot they are not likely to find is likely to make them angry.
     
  3. macrumors 68030

    Catfish_Man

    #3
    Writing to the application bundle will break code signing, if you use it. It's generally not recommended.
     

Share This Page