5
6

More than 5 years have passed since last update.

Objective-Cでの丸投げ(委譲)

Last updated at Posted at 2014-03-15

Objective-Cは丸投げ処理を比較的簡単に書けます。

こんな感じで

- (id)forwardingTargetForSelector:(SEL)aSelector
{

  if ([subcontractor respondsToSelector:aSelector]) {
      return subcontractor;
  } else {
      return [super forwardingTargetForSelector:aSelector];
  }
}

丸投げするメソッドをまとめたカテゴリーを定義しておかないとエラーになるので実装の手間が省けるぐらいかもしれませんですが。。。

5
6
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
5
6