Adding a breakpoint in XCode has shown me that a Swift 1.2 ACAccount object has a _properties object, which in turn holds the key/value pair of @user_id: 0123456789. I need to access this numerical value. I have read the docs, Googled, SO'ed and blindly tried all of the following to no avail:
let accountStore = ACAccountStore()
let accountType = accountStore.accountTypeWithAccountTypeIdentifier( ACAccountTypeIdentifierTwitter )
let allACAccounts = accountStore.accountsWithAccountType( accountType )
let someACAccount = allACAccounts[ 0 ]
someACAccount.valueForKey( "properties" )
someACAccount.mutableArrayValueForKey( "properties" )
someACAccount.valueForKeyPath( "properties" )
someACAccount.valueForUndefinedKey("properties")
someACAccount.valueForKey( "user_id" )
someACAccount.mutableArrayValueForKey( "user_id" )
someACAccount.valueForKeyPath( "user_id" )
someACAccount.valueForUndefinedKey("user_id")
someACAccount.properties
someACAccount._properties
someACAccount.user_id
someACAccount.valueForKey( "properties" ) - both spelled "properties" and "_properties" - produces the result of a Builtin.RawPointer. I do not know if that is useful or not.
It might be easier to take a more strongly-typed approach, the following works for me on a fresh iOS project:
let store = ACAccountStore()
let type = store.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)
store.requestAccessToAccountsWithType(type, options: nil) { success, error in
if success, let accounts = store.accountsWithAccountType(type),
account = accounts.first as? ACAccount
{
println(account.username)
if let properties = account.valueForKey("properties") as? [String:String],
user_id = properties["user_id"] {
println(user_id)
}
}
}