ios - Value of type '() -> ()' can never be nil
本文介绍了ios - Value of type '() -> ()' can never be nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
1.升级Xcode之后,之前代码报错,报 Value of type '() -> ()' can never be nil, comparison isn't allowed
2.相关代码
if (self.action == nil) {
return;
}
self.action == nil 报错了。
if refreshTempAction != nil {
refreshStatus = .Refresh
self.startAnimation()
UIView.animateWithDuration(0.25, animations: { () -> Void in
if scrollView.contentInset.top == 0 {
scrollView.contentInset = UIEdgeInsetsMake(self.getNavigationHeight(), 0, scrollView.contentInset.bottom, 0)
}else{
scrollView.contentInset = UIEdgeInsetsMake(ZLSwithRefreshHeadViewHeight + scrollView.contentInset.top, 0, scrollView.contentInset.bottom, 0)
}
})
refreshTempAcstion != nil 报错。
解决方案
看了你的乱糟糟的问题和与 @酷酷的哀殿 的评论后回答:
你定义的 action 都是不可空类型,你当然不能去判断是否为空,Xcode 必然报错。
你可以把你的 (() -> ())
或者 (() -> Void)
改为 (() -> Void)?
。
PS: 以后来 SegmentFault 提问前,先稍微学习下 Markdown,或者使用它的格式化工具,你问题的排版太乱,让想帮你解答的人也很无奈,很难看明白你的问题;还有,不论是写代码还是做任何事,都要用心(你有单词拼写错误);我是不是管太宽了 ?
这篇关于ios - Value of type '() -> ()' can never be nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文