说明:方法参数名一般使用的前缀包括“ the ”、“ an ”、“ new ”。 示例:良好的风格:-(void)setTitle:(NSString*)aTitle;
Cocoa命名举例:
realPath
fullString
object
//类方法newStringnewArray良好的自定义方法命名风格:recipients = [email
recipients SortedByLastName ];newEmail = [CDCEmail email
WithSubjectLine :@"Extra Text"]; emails = [mailbox messages
ReceivedAfterDate :yesterdayDate];
当需要获取对象值的另一种类型的时候,方法命名的格式语法如下: [object
adjective +thing];[object adjective +thing+ condition ];[object adjective +thing+
input :input];
良好的自定义方法命名风格:capitalized = [name capitalized String];
- (void) setName:- (id) keyForOption:- (NSArray *) emailsForMailbox:-
-(CDCEmail *) emailForRecipients: (NSArray *) theRecipients;
-(NSString *) newName; (CDCOption *) anOption (CDCMailbox *) theMailbox;
网友评论