开发者

What are the exact names for the components of an argument?

开发者 https://www.devze.com 2023-01-31 23:21 出处:网络
Example: I have this Objective-C code: +(NSString*)stringWithString:(NSString*)string; String: is the name of the argument?

Example: I have this Objective-C code:

+(NSString*)stringWithString:(NSString*)string;

String: is the name of the argument?

NSString* is the data type of the argument?

for the last part, string I'm not sure. It's somewhat a name too. But what's the exact term?

Here's an example from the apple docs:


+ (id)dateWithTimeInterval:(NSTimeInterval)seconds sinceDate:(NSDate *)date
开发者_开发百科

seconds The number of seconds to add to date. Use a negative argument to specify a date and time before date.

date The date.


Obviously they're looking at the variable when referencing the arguments, not the name part in front of the datatype-brackets. I was always wondering how to name this thing correctly.


Here + shows that it is class function you can access it by the class not the object. first (NSString*) shows it returns an string then stringWithString this is the name and after that (NSString*)is the argument type.

and finally string is the argument which use as local parameter for the function.

Name of the function , variables and classes follow a naming convention for easy understanding about the code.

0

精彩评论

暂无评论...
验证码 换一张
取 消