Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ruhi

macrumors member
Original poster
Jun 17, 2009
70
0
What is the path where Application data can be saved which is same for all users.

Like For windows it is All Users/Application data which is same for all users and accessible by all users.

what is the path in MAC which i can use for my cocoa application.

Thanks.
Ruhi
 
/Library/Application Support/<your app name>/

Note you should not assume this: don't hard code it. As well covered in the documentation you should use NSSearchPathsForDirectoriesInDomains.

An example to get the system wide Application Support directory would be:

Code:
NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSLocalDomainMask,YES);
// Assume the first path is the only one and that at least one path is returned: you should check this and correctly handle error situations
NSString *pathToSystemApplicationSupport = (NSString *) [dirs objectAtIndex:0];

Note I typed this straight into this reply: I've not tested it at all.

Edit to add: note this gets /Library/Application Support. You need to append your app name to this. Use stringByAppendingPathComponent: as this automatically handles adding a directory separator if required.
 
Suitable Path for Application Data in Cocoa Application

Thanks a lot!!!

It worked..
:)

Thanks.
Ruhi.
 
Note that /Library/Application Support is not necessarily a good place for this, as that folder does not allow non-admins to write to it. You could set up a folder for your application (say durring install time) that would have appropriate permissions, but if you try and set it up at run time if the first person is a non-admin it won't work.

And I think that the All Users folder in Vista has similar requirements, but that this was not enforced well enough in XP and before (gaping security hole).

Oh... and you might as well get used to Mac rather than MAC. Mac is short for Macintosh (so it technically should be "Mac."), not an acronym.
 
Generally (wrt to preferences etc) you should save the data on a user specific basis so that different users can have different preferences.

Additionally computer programs these days should assume users aren't running as admin as running as admin is a security risk - this is especially an issue in corporate IT.

For what its worth what exactly do you need to save that requires it to be the same for all users of the computer?
 
Oh... and you might as well get used to Mac rather than MAC. Mac is short for Macintosh (so it technically should be "Mac."), not an acronym.

Not to mention MAC is an acronym, for something completely different :) (Media Access Control)
 
Generally (wrt to preferences etc) you should save the data on a user specific basis so that different users can have different preferences.

Additionally computer programs these days should assume users aren't running as admin as running as admin is a security risk - this is especially an issue in corporate IT.

For what its worth what exactly do you need to save that requires it to be the same for all users of the computer?

I agree with all that, but there are reasons to save to /Library instead of ~/Library. For example when I still had enough time to work on Poster Paint I offered the ability to load any bitmap as the background for the image (like the checker-board Photoshop displays). When the user chose to add a background image I'd pop up a message asking if they wanted to add it for themselves only or for all users. If it was for all users then I used AuthenticationServices to get admin rights and ran an external executable as admin to copy the file. Amazingly complex for a very simple outcome!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.