Class Name with a “+”

前端 未结 2 1073
情话喂你
情话喂你 2021-01-24 19:17

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 name

2条回答
  •  [愿得一人]
    2021-01-24 19:53

    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
    

    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

提交回复
热议问题