Posts Tagged “caching”

(This post was adapted from an email I sent to Mike Solomon).

Objective-C has a method caching mechanism that optimizes for the case where a small number of methods are called repeatedly on one (or more) objects of a given class. This happens very often; for example, if you iterate over an array to gather the results of performing an operation on each element, you’re going to be calling the same method on a bunch of instances of the same class. And in fact the -[NSEnumerator nextObject] method itself will also be cached.

The fact that method caching exists is common knowledge. However, what isn’t generally known is how that caching is implemented, and what it means for you if you want to hack around on the internals of a class.

Read the rest of this entry »

Comments Comments Off on Objective-C caching and Method Swizzling