Query for permission and privilege?

Discussion in 'Mac Programming' started by newformac, Jun 18, 2011.

  1. macrumors regular

    Joined:
    May 24, 2011
    #1
    Hi all,

    i m create a file in "/Library/Preferences/file.plist"
    its working fine when i handle this from admin but when i m trying to create or write from other user its not done.

    i want to ask the location where each and every user of pc can easy access (create/read/write) file and folder.

    thanks in advance.
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You are only "guaranteed" read/write access for the user in their own home directory.

    And don't hard code paths. Use NSHomeDirectory(), NSSearchPathForDirectoriesInDomains(), etc. to find common folders.
     
  3. thread starter macrumors regular

    Joined:
    May 24, 2011
    #3
    this gives the path of currently login user.

    so when i create the file in this location and if i login with another user how can i access this file.

    i want to access a single file by all users.
     
  4. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    1. DON'T DO THAT!!!!

    Preferences are per user. They NEVER go into /Library.

    2. DON'T DO THAT!!!

    Use NSUserDefaults to handle all the preferences. Do NOT create files yourself.

    3. Use NSWorkspace to find where to put files. Especially if you want to ever get an app on the app store.
     
  5. thread starter macrumors regular

    Joined:
    May 24, 2011
    #5
    please tell me how?
     
  6. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #6
    Let me see...

    If you are using XCode 4, Press Command-Shift-2, then click on "Documentation".

    As a little test, how would you get the shared NSUserDefaults instance?

    If you can't find out, you should give up writing software.
     
  7. thread starter macrumors regular

    Joined:
    May 24, 2011
    #7
    thanks
     

Share This Page