当前位置: 首页>移动开发>正文

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"];

 

技术改变世界

https://www.xamrdz.com/mobile/44u1987408.html

相关文章: