4 ms·
Yeah, but it's pretty much impossible to accidentally do so (as demonstrated in this case). Objective-C has a lot of reflection built in - you can determine an
by potatolicious 11y ago
Yeah, but it's pretty much impossible to accidentally do so (as demonstrated in this case).
Objective-C has a lot of reflection built in - you can determine an object's class, methods, and even swap out the implementations of methods at runtime.
So it's pretty trivial to do something like:
if ([someObject respondsToSelector:@selector(_privateMethodName)]) {
[someObject performSelector:@selector(_privateMethodName)];
}
Apple scans for the easy to detect uses of this (i.e., string literals of private methods in the binary), but of course anyone sufficiently determined to get around it, can.
In this case though it's not so much accessing a private method but relying on undocumented and non-guaranteed behavior - walking a view hierarchy looking for a particular view that has no exposed interface. This sort of hackery is highly fragile (it can and does change between releases of iOS), and IMO should not be allowed in a shipping codebase.