Guidelines for naming classes in Objective-C

后端 未结 4 2038
孤街浪徒
孤街浪徒 2020-12-18 07:48

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, n

4条回答
  •  一生所求
    2020-12-18 08:10

    Scott Stevenson has some recommended guidelines for class naming here:

    http://cocoadevcentral.com/articles/000082.php

    http://cocoadevcentral.com/articles/000083.php

    From that article:

    Whether they're a standard part of Cocoa or your own creation, class names are always capitalized.

    Objective-C doesn't have namespaces, so prefix your class names with initials. This avoids "namespace collision," which is a situation where two pieces of code have the same name but do different things. Classes created by Cocoa Dev Central would probably be prefixed with "CDC".

    If you subclass a standard Cocoa class, it's good idea to combine your prefix with the superclass name, such as CDCTableView.

提交回复
热议问题