首页 > 开发 > iOS > 正文

swift中协议的命名及编码规范

2017-09-08 13:45:07  来源:网友分享

这是我写的协议:

protocol CQCollectCellDelegate {    /** cell上的分享按钮点击时回调 */    func tableViewCell(tableViewCell: CQCollectCell, didClickShareButton shareButton: UIButton)}

我这种命名规范吗?

我是参照的官方的写法:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)

swift的编码规范我还没有研究。你们如果有比较好的关于swift编码规范的文档希望可以分享一下。?

解决方案

iOS(Objc 和 Swift)的代理协议默认第一个参数是被代理者本身,是规范的。

Google 搜索 Swift 规范