带有"+"号的类名 [英] Class Name with a "+"
问题描述
我正在Xcode上开发一个iOS项目,并且看到一些类的名称带有"+"号;例如:
TableViewController+TableView.h
,然后将该类命名为:@interface RKTableViewController (TableView)
,而不是RKTableViewController+TableView
.
I am working on an iOS project in Xcode and I see some classes that have names with a "+"; for example:
TableViewController+TableView.h
and then the class is named: @interface RKTableViewController (TableView)
as opposed to RKTableViewController+TableView
.
这是什么+
和(TableView)
?如果其子类UITableView
不应该声明为该类:Subclassed name : Parent class name
format?
What is this +
and the (TableView)
? If its subclassing UITableView
shouldn't the class be declared as: Subclassed name : Parent class name
format?
推荐答案
文件名中的+在语义上并不重要.命名文件"ClassName + CategoryName.h/m"只是用于命名包含类别的文件的常用约定.
The + in the filename isn't semantically important. Naming a file "ClassName+CategoryName.h/m" is just a popular convention for naming files containing categories.
@interface RKTableViewController (TableView)
@end
在RKTableViewController
类上声明一个名为"TableView"的类别.类别用于将方法添加到其主要实现之外的类.请参阅以下类别中的Apple文档: http: //developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/chapters/occategories.html
declares a category called "TableView" on the RKTableViewController
class. Categories are used to add methods to a class outside its main implementation. See the Apple documentation on categories here: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/chapters/occategories.html
这篇关于带有"+"号的类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!