如果你有一个类的对象,它只是信息for one店铺。
该对象描述了一个店铺信息。
通常使用这种方式编写类名,它使得使用物体时的感觉.
尤其是方法名和变量声明更加清晰
// CORRECT WAY
- (UIAlertView *)calculateSomething:(UIView I)view {
UIView *newView = view;
...
return [UIAlertView alertWith...];
}
在我看来,使用复数形式会很奇怪(看起来单个对象不止一个!):
// BAD IDEA
- (UIAlertViews *)calculateSomething:(UIViews *)view {
UIViews *newView = view;
...
return [UIAlertViews alertWith...];
}
然后,您可以轻松地使用该对象或测试该类,这也很有意义:
[myObject isKindOfClass:[NSString class]]
这是如何写名字的官方链接:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-BBCHBFAH https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-BBCHBFAH
你看,苹果总是避免使用复数形式(NSString、NSArray 等)。
当然,反之亦然,但对于类方法等来说更多。其他流行语言也对类使用单数形式。
其他一些好的编码指南来自可可开发中心
http://cocoadevcentral.com/articles/000082.php http://cocoadevcentral.com/articles/000082.php
http://cocoadevcentral.com/articles/000083.php http://cocoadevcentral.com/articles/000083.php