ios - Value of type '() -> ()' can never be nil
怪我咯
怪我咯 2017-04-18 09:27:49
0
1
384

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 报错。

怪我咯
怪我咯

走同样的路,发现不同的人生

Antworte allen(1)
阿神

看了你的“乱糟糟”的问题和与 @酷酷的哀殿 的评论后回答:

你定义的 action 都是不可空类型,你当然不能去判断是否为空,Xcode 必然报错。
你可以把你的 (() -> ()) 或者 (() -> Void) 改为 (() -> Void)?

PS: 以后来 SegmentFault 提问前,先稍微学习下 Markdown,或者使用它的格式化工具,你问题的排版太乱,让想帮你解答的人也很无奈,很难看明白你的问题;还有,不论是写代码还是做任何事,都要用心(你有单词拼写错误);我是不是管太宽了

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!