首页 > 代码库 > 【OC语法快览】一、方法调用

【OC语法快览】一、方法调用



调用方法


[object  method];
[object methodWithInput:input];

output = [object methodWithOutput];
output = [object methodWithInputAndOutput:input];

id myObject = [NSString string];
NSString* myString = [NSString string];



嵌套消息


function1 ( function2() );
[NSString stringWithFormat:[prefs format]];





多个输入参数的方法


-(BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;
BOOL result = [myData writeToFile:@"/tmp/log.txt"atomically:NO];




原文:learn_objective_C part 1