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

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

怪我咯
怪我咯

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

reply all(1)
阿神

After reading your “messed up” question and the comments with @ Cool Ai Dian, I answered:

The actions you define are all non-nullable types. Of course, you cannot judge whether they are empty or not. Xcode will definitely report an error.
You can put your (() -> ()) 或者 (() -> Void) 改为 (() -> Void)?.

PS: Before coming to SegmentFault to ask questions in the future, please learn a little bit about Markdown, or use its formatting tool. The formatting of your question is too messy, which makes people who want to help you answer helpless and difficult to understand your question. ; Also, whether you are writing code or doing anything, you must be careful (you have a spelling mistake); am I being too lenient?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!