Objective-C Basic

1. Methods and Messages

 a) class method - call it by sending a message to the class itself
 b) instance method - call it by sending a message to an instance of the class
 
An Objective-C method’s name must contain exactly as many colons as the method
takes parameters, and, the parameter name must end with a colon

 
 c) Calling a Method
 eg:
 NSString* s = @"Hello, world!";
 NSString* s2 = [s uppercaseString];
 <=>
 NSString* s2 = [@"Hello, world!" uppercaseString];
 
 //If a method takes no parameters, then its name contains no colons
 //If a method takes two or more parameters, its name contains that number of colons
 eg:
 [someObject hereAreThreeStrings: @"string1" : @"string2" : @"string3"];

 

Reproduced in: https: //www.cnblogs.com/davidgu/p/3453939.html

Guess you like

Origin blog.csdn.net/weixin_33998125/article/details/93802904