Succession in methods


#1

(eventually it’s an overall issue)
discovered, still observing the BMI example :open_mouth: , that:
generating an output with NSLog the computer doesn’t start to print out the text and then takes one format specifier after the other, but start collecting where the format specifiers are pointing to! all of them! before printing whats inside the “” !
like


-(int)result
{
NSLog(@"I am first")
return 1;
}
-(NSString *) showMe
{
NSLog (@" show me %d", [self result]);
}

got me?

I discovered that with an NSLog in the Employee.m description-method AND valueOfAssets-method,
and i was very surpised.
but after a thought, it’s very necessary like this.


#2

Do you mean the output from the NSLog statements are being buffered before being sent to the final destination, the console?


#3

Correct. Function calls and method invocations are always resolved from the inside out. That means that [self result] must execute and return before NSLog() is actually called, and passed the return value of [self result] as an argument.