__typeof在Xcode7中的使用

来源:互联网 发布:淘宝多琳香水是正品么 编辑:程序博客网 时间:2024/06/05 05:43

前段时间做的时候就遇到了这个问题,今天把它记录下来。就是之前的代码明明没有问题可是应用到xcode7.3和ios9.3以后就出现了错误提示。
如下代码:这个是类库中的一段代码,在之前是没有问题的,但是用到新的环境中竟然报错
__weak typeof(self) weakSelf = self;
_FDViewControllerWillAppearInjectBlock block = ^(UIViewController *viewController, BOOL animated) {
__strong __typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
[strongSelf setNavigationBarHidden:viewController.fd_prefersNavigationBarHidden animated:animated];
}
};
然后修改错误也很简单,只是还不懂有什么大的区别,先记录下来。就是__typeoftypeof的区别

 __weak __typeof(self) weakSelf = self;_FDViewControllerWillAppearInjectBlock block = ^(UIViewController *viewController, BOOL animated) {    __strong __typeof(weakSelf) strongSelf = weakSelf;    if (strongSelf) {        [strongSelf setNavigationBarHidden:viewController.fd_prefersNavigationBarHidden animated:animated];    }};
0 0