码迷,mamicode.com
首页 > 移动开发 > 详细

xcode8 iOS函数返回值使用警告

时间:2017-04-26 14:39:24      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:swift   没有   imp   not   div   mat   cal   func   card   

没有使用返回值时, 警告

swift:

@warn_unused_result func doSomething() -> Bool {
  return true
}

OC:

- (BOOL)doSomething __attribute__((warn_unused_result)) {
  return YES;
}

 

没有使用返回值时, 不警告

swift:

@discardableResult func doSomething() -> Bool {
  return true
}

OC:

To prevent the compiler from flooding us with warnings when importing Objective-C code the @discardableResult attribute is automatically added for all non-void functions that are not marked with the ((warn_unused_result)) attribute.

xcode8 iOS函数返回值使用警告

标签:swift   没有   imp   not   div   mat   cal   func   card   

原文地址:http://www.cnblogs.com/Rinpe/p/6768243.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!