0

Is there any API available to Swift that provides the name (which should be an email address, AFAIK) of the Apple ID associated with the current macOS user?

The following command line seems to provide the correct info, but I'd prefer not to have to run a separate Process to get this info in my Swift code:

defaults read MobileMeAccounts | plutil -extract "Accounts".0."AccountID" raw -o - -

Thanks.

1

1 Answer 1

0

Found the answer myself:

(UserDefaults.standard.persistentDomain(forName: "MobileMeAccounts")?["Accounts"] as? [[String: Any]])?.first?["AccountID"]

If anyone knows a more concise answer, please let me know.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.