In the following example how many messages are sent to myObject?
- (void) myMethod:(id) myObject
NSLog(@"%@", myObject.myStringProperty);
NSLog(@"%@", myObject.myStringProperty);
NSLog(@"%@", myObject.myStringProperty);
}
I’m just curious about Objective-c potentially caching the value returned by myStringProperty on the stack. The value returned by myStringProperty could change between successive messages so perhaps caching doesn’t make sense.
Three
Nope, it’s not cached. Every objc message is sent, provided of course
myObjectis notnil.The compiler has no idea about any side effects within the method’s execution (1) or influence of the global state (2).
myStringProperty?