我试图在我的块调用中创建视图控制器,当它从块返回时,我的对象变为 nil。如何解决?
我的块声明:
typedef void (^GetViewController)(UIViewController *viewController, int index);
需要 VC 时调用块(viewController 现在为零)
self.getViewController(viewController, index);
在另一个类中设置 VC
self.myController.getViewController = ^(UIViewController *viewController, int index)
{
switch (index) {
case Option1:
viewController = [[Option1VC alloc] init];
break;
case Option2:
viewController = [[Option1VC alloc] init];
break;
default:
break;
}
//at this point VC is created
};