Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
パラメータの渡し方
-(void)errorValue:(void(^)(NSError*))error{ [self errMssg]; } -(void)call{ (void(^)(NSError*))error; [self errorValue ?]; }
メソッドに (void(^)(NSError*))error を渡す方法を教えてください!
@よろしくお願いします
最初にブロック変数を適切に宣言する必要があります。次に、他の変数と同じように名前で渡します。
void(^myBlock)(NSError *) = ^(NSError* error) { // Do something }; [self errorValue:myBlock];
または、ブロック リテラルを直接渡すこともできます。
[self errorValue:^(NSError* error) { // Do something }];