我试图使用Objective将数据从我的ViewController传递到TabBarController。我试图将一些数据分配给"bottomTabEventList“(这是我的自定义TabBarController类的属性)。不幸的是,我的程序通过提供未识别的选择器实例错误/警告而崩溃。
在TabBarController类的自定义头中,名为BottomTabview:
@interface BottomTabView : UITabBarController <UITabBarControllerDelegate>
@property(strong,nonatomic)EventList *bottomTabEventList;
@end和ViewController.m中的prepareForSegue方法
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
BottomTabView *btw = [segue destinationViewController];
//checking
if(btw == nil)
NSLog(@"btw in viewController is nil");
else
NSLog(@"btw in viewController is NOT nil");
if(self.eventList.eventList == nil)
NSLog(@"eventList in viewController is nil");
else
NSLog(@"eventList in viewController is NOT nil"); //end of checking
btw.bottomTabEventList = self.eventList; //This is where crash appears
}准确的坠机日志是:
-ViewController setBottomTabEventList::未识别的选择器发送到实例0x7fe923c6ba00 *终止应用程序,原因是'NSInvalidArgumentException',原因:'-ViewController setBottomTabEventList::未识别的选择器发送到实例0x7fe923c6ba00‘
Segue是从ViewController到BottomTabView,它的类型是“现在模式”。如果你能帮我/指导我,我会非常感激的。提前谢谢。
发布于 2015-09-28 08:48:54
问题似乎是,btw实际上不是BottomTabView类型的,只是一个UIViewController,因此崩溃日志提供:
ViewController setBottomTabEventList::发送到实例的未识别选择器
因为UIViewController不知道BottomTabEventList是什么。
您需要确保btw实际上是一个BottomTabView实例。
稍微反省一下,我敢打赌这句话不会涉及到以下内容:
if ([btw isKindOfClass:[BottomTabView class]]){
btw.bottomTabEventList = self.eventList;
}https://stackoverflow.com/questions/32818735
复制相似问题