在 Xcode 中自动实现 Swift 协议方法 [英] Auto-implement Swift protocol methods in Xcode

查看:39
本文介绍了在 Xcode 中自动实现 Swift 协议方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 swift 语言,从 java 开始,到目前为止看起来很棒.但我真的错过了一些东西:

I just started with the swift language and coming from java it looks great so far. But I'm really missing something:

Eclipse 有一个很棒的功能,当我添加implements XYZ"时,它为我提供了一个功能来自动实现必要的功能存根.这节省了大量时间.

Eclipse had this great feature that when I added "implements XYZ" it provided me a function to automatically implement the necessary function stubs. This is a huge timesaver.

Xcode 好像没有这个功能,还是我遗漏了什么?

Xcode doesn't seem to have this feature, or am I missing something?

我找到了 accessorize 插件,但这似乎只适用于 Objective C..

I found the accessorize plugin, but this seems only to work with Objective C..

有解决办法吗?

附注.我使用的是 Xcode 6.1.1

PS. I'm using Xcode 6.1.1

推荐答案

Xcode 9

Xcode 9 现在支持通过修复"来符合协议方法.它会自动为您填充缺失的方法.这是在 WWDC 2017 上宣布的.

Xcode 9

Xcode 9 now supports conforming to protocol methods via a "fix it". It will automatically fill the missing methods for you. This was announced in WWDC 2017.

更新:不幸的是,这似乎不适用于您定义的协议.

Update: This doesn't seem to work for protocols defined by you, unfortunately.

这篇关于在 Xcode 中自动实现 Swift 协议方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆