在Objective-C中命名类的指南 [英] Guidelines for naming classes in Objective-C

查看:108
本文介绍了在Objective-C中命名类的指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,Objective-C中没有命名空间,这是一回事。但是当一个项目的大小和文件增加,并且UITableCellViews和其他子视图被添加,命名我的类倾向于成为一个真正的痛苦。

First of all, there are no namespaces in Objective-C, that's one thing. But when a project increases in size and files, and UITableCellViews and other subviews are added, naming my classes tend to become a real pain..

例如使用一个名为EEMSystem在一个表中,我自然的方式来命名自定义UITableViewCell将类似EEMSystemTableViewCellController.m。这创建了真正长的类名。

For example using a model named EEMSystem in a table, my natural way to name the custom UITableViewCell would be something like EEMSystemTableViewCellController.m. This creates really long class names..

有什么指导命名控制器,视图和模型?你使用什么指导?

Are there any guidelines for naming controllers, views and models? What guidelines are you using?

推荐答案

Cocoa的编码指南对Cocoa中的命名约定有一些基本的建议,但它主要涉及方法名称。

The Coding Guidelines for Cocoa have some basic advice on naming conventions in Cocoa, but it mostly relates to method names. Generally, it's not unusual that names in Cocoa are pretty long.

在你的示例中,我将命名为 EEMSystemTableViewCell 或简单地 EEMSystemCell EEMSystemTableViewCellController 会暗示该类是一个控制器,虽然它实际上是一个视图。

In your example, I would name the class either EEMSystemTableViewCell or simply EEMSystemCell. EEMSystemTableViewCellController would imply that the class is a controller although it's actually a view.

这篇关于在Objective-C中命名类的指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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