Please let me know how to get the currently logged-in user's user id in Objective-C. I would like to get the user id of the logged-in user that's currently using the computer locally. My command-line program is running as root and I want to find the currently logged-in user's user id. Thanks.
SCDynamicStoreCopyConsoleUser() might work for you. It will return uid and gid of the current console user.