Mac Developer Library

Developer

Accounts Framework Reference ACAccountStore Class Reference

Options
Deployment Target:

On This Page
Language:

ACAccountStore

The ACAccountStore class provides an interface for accessing, manipulating, and storing accounts. To create and retrieve accounts from the Accounts database, you must create an ACAccountStore object. Each ACAccount object belongs to a single ACAccountStore object.

Inheritance


Conforms To


Import Statement


Swift

import Accounts

Objective-C

@import Accounts;

Availability


Available in OS X v10.8 and later.
  • accounts accounts Property

    The accounts managed by this account store. (read-only)

    Declaration

    Swift

    var accounts: [AnyObject]! { get }

    Objective-C

    @property(readonly, weak, atomic) NSArray *accounts

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

  • Returns the account with the specified identifier.

    Declaration

    Swift

    func accountWithIdentifier(_ identifier: String!) -> ACAccount!

    Objective-C

    - (ACAccount *)accountWithIdentifier:(NSString *)identifier

    Parameters

    identifier

    A unique identifier for an account.

    Return Value

    The account that matches the value specified in identifier.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

    See Also

    identifier

  • Returns all accounts of the specified type.

    Declaration

    Swift

    func accountsWithAccountType(_ accountType: ACAccountType!) -> [AnyObject]!

    Objective-C

    - (NSArray *)accountsWithAccountType:(ACAccountType *)accountType

    Parameters

    accountType

    The type of an account.

    Return Value

    All accounts that match accountType.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

    See Also

    accountType

  • Renews account credentials when the credentials are no longer valid.

    Declaration

    Swift

    func renewCredentialsForAccount(_ account: ACAccount!, completion completionHandler: ACAccountStoreCredentialRenewalHandler!)

    Objective-C

    - (void)renewCredentialsForAccount:(ACAccount *)account completion:(ACAccountStoreCredentialRenewalHandler)completionHandler

    Parameters

    account

    The account to renew credentials.

    completionHandler

    The handler to call when the renewal has completed.

    Discussion

    For Twitter and Sina Weibo accounts, this method will prompt the user to go to Settings to re-enter their password.

    For Facebook accounts, if the access token has become invalid due to a regular expiration, this method will obtain a new one.

    If the user has deauthorized your app, this renewal request will return ACAccountCredentialRenewResultRejected.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

Data Types

  • Specifies a handler to call when an Accounts database operation is complete.

    Declaration

    Swift

    typealias ACAccountStoreSaveCompletionHandler = (Bool, NSError!) -> Void

    Objective-C

    typedef void(^ACAccountStoreSaveCompletionHandler)(BOOL success, NSError *error);

    Discussion

    The completion handler parameters are:

    success

    A Boolean value indicating whether the operation is successful. YEStrue if the operation is successful; otherwise NOfalse.

    error

    An error, if one occurred.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

  • Specifies a handler to call when an account is removed from the store.

    Declaration

    Swift

    typealias ACAccountStoreRemoveCompletionHandler = (Bool, NSError!) -> Void

    Objective-C

    typedef void(^ACAccountStoreRemoveCompletionHandler)(BOOL success, NSError *error);

    Discussion

    The completion handler parameters are:

    success

    A Boolean value indicating whether the operation was successful. YEStrue if successful; otherwise NOfalse.

    error

    An error, if one occurred.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

  • Specifies a handler to call when access is granted or denied.

    Declaration

    Swift

    typealias ACAccountStoreRequestAccessCompletionHandler = (Bool, NSError!) -> Void

    Objective-C

    typedef void(^ACAccountStoreRequestAccessCompletionHandler)(BOOL granted, NSError *error);

    Discussion

    The completion handler parameters are:

    granted

    A Boolean value indicating whether access is granted. YEStrue if access is granted; otherwise NOfalse.

    error

    An error, if one occurred.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

  • Specifies a handler to call when credentials are renewed.

    Declaration

    Swift

    typealias ACAccountStoreCredentialRenewalHandler = (ACAccountCredentialRenewResult, NSError!) -> Void

    Objective-C

    typedef void(^ACAccountStoreCredentialRenewalHandler)(ACAccountCredentialRenewResult renewResult, NSError *error);

    Discussion

    The renewal handler parameters are:

    renewResult

    The result of the renewal request.

    error

    An error, if one occurred.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

  • Options dictionary keys supporting requests to Facebook accounts.

    Declaration

    Swift

    let ACFacebookAppIdKey: NSString! let ACFacebookPermissionsKey: NSString! let ACFacebookAudienceKey: NSString!

    Objective-C

    NSString *ACFacebookAppIdKey; NSString *ACFacebookPermissionsKey; NSString *ACFacebookAudienceKey;

    Constants

    • ACFacebookAppIdKey

      ACFacebookAppIdKey

      The Facebook App ID, as it appears on the Facebook website.

      Available in OS X v10.8 and later.

    • ACFacebookPermissionsKey

      ACFacebookPermissionsKey

      The array of strings of permissions to request (e.g. email, publish_stream, etc.).

      Available in OS X v10.8 and later.

    • ACFacebookAudienceKey

      ACFacebookAudienceKey

      Only required when posting permissions are requested.

      Available in OS X v10.8 and later.

  • Options dictionary values supporting requests to Facebook accounts.

    Declaration

    Swift

    let ACFacebookAudienceEveryone: NSString! let ACFacebookAudienceFriends: NSString! let ACFacebookAudienceOnlyMe: NSString!

    Objective-C

    NSString *ACFacebookAudienceEveryone; NSString *ACFacebookAudienceFriends; NSString *ACFacebookAudienceOnlyMe;

    Constants

    • ACFacebookAudienceEveryone

      ACFacebookAudienceEveryone

      Posts are visible to everyone.

      Available in OS X v10.8 and later.

    • ACFacebookAudienceFriends

      ACFacebookAudienceFriends

      Posts are visible only to friends.

      Available in OS X v10.8 and later.

    • ACFacebookAudienceOnlyMe

      ACFacebookAudienceOnlyMe

      Posts are visible to the user only.

      Available in OS X v10.8 and later.

  • Options dictionary keys supporting requests to LinkedIn accounts.

    Declaration

    Swift

    let ACLinkedInAppIdKey: NSString! let ACLinkedInPermissionsKey: NSString!

    Objective-C

    NSString *ACLinkedInAppIdKey; NSString *ACLinkedInPermissionsKey;

    Constants

    • ACLinkedInAppIdKey

      ACLinkedInAppIdKey

      The LinkedIn App ID, as it appears on the LinkedIn website.

      Available in OS X v10.9 and later.

    • ACLinkedInPermissionsKey

      ACLinkedInPermissionsKey

      The array of strings of permissions to request.

      Available in OS X v10.9 and later.

  • Options dictionary keys supporting requests to Tencent Weibo accounts.

    Declaration

    Swift

    let ACTencentWeiboAppIdKey: NSString!

    Objective-C

    NSString *ACTencentWeiboAppIdKey;

    Constants

    • ACTencentWeiboAppIdKey

      ACTencentWeiboAppIdKey

      The Tencent Weibo App ID, as it appears on the Tencent Weibo website.

      Available in OS X v10.9 and later.

  • Status codes of credential renewal requests.

    Declaration

    Swift

    enum ACAccountCredentialRenewResult : Int { case Renewed case Rejected case Failed }

    Objective-C

    typedef enum { ACAccountCredentialRenewResultRenewed, ACAccountCredentialRenewResultRejected, ACAccountCredentialRenewResultFailed } ACAccountCredentialRenewResult;

    Constants

    • Renewed

      ACAccountCredentialRenewResultRenewed

      The account’s credentials have been renewed and are now associated with the account.

      Available in OS X v10.8 and later.

    • Rejected

      ACAccountCredentialRenewResultRejected

      Renewal failed because the user revoked your access to their account.

      Available in OS X v10.8 and later.

    • Failed

      ACAccountCredentialRenewResultFailed

      A non-user-initiated cancel of the prompt. Try again.

      Available in OS X v10.8 and later.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.

  • Posted when the accounts managed by this account store changed in the database. There is no userInfo dictionary associated with this notification.

    This notification is sent if an account is saved or removed locally or externally. If you receive this notification, you should refetch all account objects.

    Import Statement

    Objective-C

    @import Accounts;

    Swift

    import Accounts

    Availability

    Available in OS X v10.8 and later.