PDA

View Full Version : Query for permission and privilege?




newformac
Jun 18, 2011, 02:21 AM
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.



kainjow
Jun 18, 2011, 02:58 AM
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.

newformac
Jun 18, 2011, 03:15 AM
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.

gnasher729
Jun 18, 2011, 03:22 AM
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.

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.

newformac
Jun 18, 2011, 03:47 AM
please tell me how?

gnasher729
Jun 18, 2011, 04:22 AM
please tell me how?

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.

newformac
Jul 1, 2011, 04:55 AM
thanks