Xcode:可以为Protocol接口所需的方法自动创建存根吗? [英] Xcode: Possible to auto-create stubs for methods required by Protocol interface?

查看:295
本文介绍了Xcode:可以为Protocol接口所需的方法自动创建存根吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自Eclipse / Java背景,我最喜欢的功能之一是能够快速存根接口所需的所有方法。在Eclipse中,我可以从源菜单中选择'Override / implement'来为接口的任何方法生成存根方法。

Coming from an Eclipse / Java background, one of my favorite features is the ability to quickly stub out all the methods required by an interface. In Eclipse, I can choose 'Override / implement' from the source menu to generate stub methods for any method of the Interface.

我想做同样的事情在Objective-C中。例如,如果我声明一个实现'NSCoding'协议的类,我想让Xcode自动生成实现此协议所需的方法。令我很沮丧的是必须查找,然后复制/粘贴我正在尝试实现的每个协议所需方法的签名。

I'd like to do the same thing in Objective-C. For instance, if I declare a class that implements the 'NSCoding' protocol, I'd like to have Xcode automatically generate the methods required to implement this Protocol. It's frustrating to have to look-up and then copy/paste the signatures of the required methods every Protocol that I'm trying to implement.

我一直在努力一段时间来了解这是否可行,但尚未找到任何有希望的东西。这是可能的XCode中?

I've been trying for awhile to find out if this is possible, but haven't found anything promising yet. Is this possible in XCode?

推荐答案

Accessorizer将写入传递给它的ivars(NSCoding协议和用于NSDocument编码和解码方法存档)。它还会生成字符串常量static或带有自定义前缀的#define; copyWithZone:;以及其他需要的东西 - 所有这些都可以通过服务或工具栏中的简单快捷方式实现。 配置器密钥存档

Accessorizer will write the encode and decode methods for ivars passed to it (NSCoding protocol and for NSDocument archiving). It will also generate string constants either static or #define with a custom prefix; copyWithZone:; and other things if you need - all from a simple shortcut via Services or from the toolbar. Accessorizer keyed archiving

这篇关于Xcode:可以为Protocol接口所需的方法自动创建存根吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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