23
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ACAccount Twitterのuser_idを取得する

Last updated at Posted at 2013-03-05

ACAccountからTwitterのuser_idを取得する方法です。

実装

ACAccountのカテゴリにしました。

ACAccount+Extras.h
@interface ACAccount (Extras)

- (NSString*)user_id_String;

@end
ACAccount+Extras.m
@implementation ACAccount (Extras)

- (NSString *)user_id_String
{
    NSString *idStr = [self valueForKeyPath:@"properties.user_id"];
	// 今後の仕様変更に備えて確認
    NSAssert1(idStr != nil && [idStr isKindOfClass:[NSString class]] , @"ACAccount(Extras) %@", self);
    return idStr;
}

@end

補足

Twitterでは特定のユーザーを指定する方法でuser_idscreen_nameがあります。
screen_nameはACAccountのusernameで取得出来ます。screen_name変更することも出来ます。

user_idscreen_nameが変更されても変更されることのないユーザーを識別する一意の値ですので、ユーザー管理は基本user_idでした方がよいかと思われます。

参考

23
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?