After swapping the -objectAtIndex: method using method_exchangeImplementations, it will cause continuous memory growth.
- Connect the iPhone and run the provided project.
- Continuously tap the iPhone screen.
- Observe Memory; it will keep growing.
What you’re doing is deeply unsupported, and I strongly recommend that you stop doing it.
In general, Apple doesn’t support folks swizzling methods on Apple’s classes. And in this case you’re swizzling methods on a class, __NSArrayM
, that’s an implementation detail. It’s never good to rely on implementation details because they could change at any time, and that would break your code.
If you explain more about your high-level goal, I may be able to suggest an alternative path forward.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"