本文主要是介绍__typeof在Xcode7中的使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前段时间做的时候就遇到了这个问题,今天把它记录下来。就是之前的代码明明没有问题可是应用到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];
}
};
然后修改错误也很简单,只是还不懂有什么大的区别,先记录下来。就是__typeof和typeof的区别
__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];}
};
这篇关于__typeof在Xcode7中的使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!