سؤال

I'm building an app in which the user will use one of his iOS integrated Twitter accounts. I'm using the Accounts Framework and in the documentation example, the account from which the request to Twitter will be performed is grabbed this way : ACAccount *twitterAccount = [accountsArray objectAtIndex:0]; so the user has no choice regarding which "TWAccount" he is using.

I will easily build an UISheet to display all Twitter accounts and let the user choose the one he wants, but my question is:

What is the proper way to store the chosen account for a long term use through the app?

Edit: Sorry my question wasn't entirely clear. I want to store it like we store other preferences for an app. So the first time the user is launching the app he has to chose which account to use, but after that he will never have to chose anymore when he'll relaunch it.

هل كانت مفيدة؟

المحلول

Store it like any other object you'd store. It's an object. Retain it. For example, under ARC you'd simply assign it to a property. Remember to register for ACAccountStoreDidChangeNotification just in case the user does something, such as deleting this account, behind your back; if the notification arrives, your supposed to release your ACAccount object and fetch it again.

The account is uniquely identified by its identifier, so on subsequent launches of your app you can fetch it again with accountWithIdentifier:.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top