+(DetailViewController *) instance{
return (DetailViewController *)[[UIApplication sharedApplication]delegate];
}
-(void)tapped:(UITapGestureRecognizer *)recognizer {
[[DetailViewController instance]showViewInFullScreen:self withModel:self.messageModel];
}
DetailViewController.m
-(void)showViewInFullScreen:(UIViewExtention*)viewToShow withModel:(MessageModel*)model{
[viewController showViewInFullScreen:viewToShow withModel:model];
}
当我到达tapped方法时无法调用在DetailViewController类中的showViewInFullScreen.And app终止时显示以下消息。
NSInvalidArgumentException',原因:
' - [AppDelegate showViewInFullScreen:withModel:]:无法识别的选择器 发送到实例
感谢。
答案 0 :(得分:0)
为什么要将应用委托转换为DetailViewController类?
如果你想创建一个DetailViewController类的单例,你需要做这样的事情(假设你使用ARC):
+(DetailViewController *) instance{
// Create a singleton instance of the class
static DetailViewController *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
}