LoginSignup
3
3

More than 5 years have passed since last update.

Block の prototype, typedef など

Posted at

戻り値が int, 引数が NSObject * だとして

// 変数 var を宣言
int(^var)(NSObject *);

// newType を宣言
typedef int(^newType)(NSObject *);

// メソッド引数として宣言
-(void)m1:(int(^)(NSObject *))blockArg;

変数宣言と typedef は関数ポインタと同じ形。

int (*var)(char *);
typedef int(*newType)(char *);
void f(int(*funcArg)(char *));

たまに間違えるけど、こうじゃない。

// これは間違い
-(void)m1:(int(^blockArg)(NSObject *))
3
3
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
3
3