Swift3.0 Result of call to 'XXX' is unused
来源:互联网 发布:算法导论pdf百度云 编辑:程序博客网 时间:2024/05/09 06:22
由于Swift3.0的安全性提高了,所以当一个函数的返回值没有变量来接收时编译器会给出警告,虽然不会对程序造成影响,但看着那么多警告确实不爽。
其实解决警告的方法有两种,第一种很简单,就是在调用函数的地方这么写:
_ = self.function()
用一个空变量来接收返回值。
第二种就是在函数定义的时候加上@discardableResult
@discardableResultfunc equalTo(_ other: Int) -> ConstraintDescriptionEditable
这样的话调用这个函数即使没有变量来接受返回值也不会报警告。
阅读全文
1 0
- Swift3.0 Result of call to 'XXX' is unused
- Swift3 - Result of call '***' is unused
- Swift Result of call to ‘XXX’ is unused
- Swift 3.0 出现 Result of all to 'XX' is unused 警告 解决
- "Expression of type "UIViewController?" is unused".
- initialization of xxx is skipped by xxx
- The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one
- integer operation result is out of range
- [解决]Marshalling Error: class XXX nor any of its super class is known to this context
- Part xxx is out of date with respect to the design cache.
- Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
- warning:Instance variable used while 'self' is not set to the result of '[(super or self) init…]'
- call of overloaded 'round(&float)' is ambiguous
- Xcode 8, Swift 3: “Expression of type UIViewController? is unused” warning
- Xcode 8 / Swift 3: “Expression of type UIViewController? is unused” warning
- Casting 'findViewById(R.id.XXX)' to 'XXX' is redundant
- swift3.0 Missing argument label 'xx:' in call
- PHP Fatal error: Call to undefined function curl_init() in xxx
- 关于FFmpeg 利用videotoolbox硬编
- [USACO1.3]滑雪课程设计Ski Course Design
- UVa213
- 在Macbook Pro上为TensorFlow设置GPU
- Android7.0中文文档(API)-- GridView
- Swift3.0 Result of call to 'XXX' is unused
- ④写给后端工程师的JavaScript教程——js有趣的非数字值NaN、Infinity
- 计算机文化学习笔记5
- Mac OSX 无共享的密钥情况下连接基于L2TP协议的VPN
- 进程池流程
- solr 对数据添加索引
- Hdu 4498 自适应辛普森积分
- Windows学习(008)--线程(一)
- 关于apk打包,报java.lang.ClassCastException:com.google.gson.internal.LinkedTreeMap cannot be cast to 的错误