多个参数的block
firstPageViewController.m
1. 在第一个页面初始化页面时申明block函数
_pickerViewController = [[TFPickerViewController alloc]init];
[_pickerViewController loadTFBlock:^(NSString *parameter1, NSString *parameter2)
{
CHDebugLog(@"block Test success data:%@---%@",parameter1,parameter2);
}];
#pragma mark -- Clicked
- (void)commitClick
{
[self.navigationController pushViewController:_pickerViewController animated:YES];
}
2. 在第二个页面对于block定义,设定回调条件。
当选择完毕picker view完毕后,获取到picker view数据后,回传到第一个页面去。
TFPickerViewController.h
typedef void (^testTFBlockParameter)(NSString *parameter1 , NSString *parameter2);
@interface TFPickerViewController : baseViewController
@property(nonatomic, weak)testTFBlockParameter blockParameter;
- (void)loadTFBlock:(testTFBlockParameter)block;
@end
TFPickerViewController.m
- (void)onSelectDataStr:(NSString*)selectStr
{
CHDebugLog(@"----%@",selectStr);
if (self.blockParameter != nil)
{
self.blockParameter(selectStr,@"test Success");
}
}
#pragma mark -- test more parameter Block
- (void)loadTFBlock:(testTFBlockParameter)block
{
self.blockParameter = block;
}
ios 多个参数的block
最新推荐文章于 2024-02-25 17:36:37 发布