addObserver:selector:name:object:suspensionBehavior:
遠隔通知センターにオブザーバーを追加します
-(void)addObserver:(id)anObserver: selector:(SEL)aSelector: name:(NSString *)notificationName: object:(NSString *)anObject: suspensionBehavior:(NSNotificationSuspensionBehavior)suspensionBehavior:
解説
遠隔通知センターにオブザーバーを追加します。
aSelectorのセレクタは1つの引数を持たなければいけません。
返り値
( void )
なし
引数
( id )anObserver
オブザーバー
( SEL )aSelector
( NSString * )notificationName
通知名
( NSString * )anObject
オブジェクト
( NSNotificationSuspensionBehavior )suspensionBehavior
通知が保留された時の挙動
● NSNotificationSuspensionBehaviorDrop
● NSNotificationSuspensionBehaviorCoalesce
● NSNotificationSuspensionBehaviorHold
● NSNotificationSuspensionBehaviorDeliverImmediately
フレームワーク
Foundation
クラス
NSDistributedNotificationCenter
Instance Methods
使用可能
10.0
参照
- postNotificationName:object:userInfo:deliverImmediately:
例文
- (id)initWithConnection:(NSConnection *)aConnection { if(self = [super init]) { myConnection = aConnection; [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(restart:) name:@"RESTART" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; } return self; } [[NSDistributedNotificationCenter defaultCenter] addObserver:self//これを呼び出す selector:@selector(serverCall:) //呼び出されるメソッド name: @"DOServer_AllNotification" // object: nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately ];