在该函数前添加 @discardableResult  即可,例如

@discardableResult func shared() -> UIView {

  return UIView()

 

}

 

以上函数的返回结果不被使用时系统不会发出警告.