I think that the majority of iOS developers somehow came across the fact that, according to the rules of Apple, it was not possible to do any functions. Often this is due to the fact that certain methods fall into the private section. When you try to publish an application using them, its rejection will follow (paragraph 2.5 of the Apple Review Guidelines).

Under the cut, I'll tell you how you can partially remove this restriction.
')
It will not be possible to hide major violations of the rules in this way, because from the functionality of your application it will be seen that it uses something forbidden (transferring files via bluetooth, for example), but for any changes to the standard UI and something similar, this method will do perfect.
So, suppose we want to change the color of the UISwitch, but on iOS 4 (tintColor appeared in iOS 5). You can do this with the following code:
[testSwitch setAlternateColors:true];
It seems that everything is simple, but this method is not in the UISwitch documentation, and therefore it cannot be used. This can be
hidden using the features of the
Objective-C Runtime.So, then a small step-by-step instruction:
- Putting NSString in pieces so that code analyzers do not notice its name entirely:
NSString *nameOfMethod = @””; for (NSString *s in [NSArray arrayWithObjects:@"set",@"Alt",@"ernate",@"Colors:",nil]) nameOfMethod = [nameOfMethod stringByAppendingString:s]; const char *nameOfMethodUTF8 = [nameOfMethod UTF8String];
- Enumerate the UISwitch methods until we find the desired one:
SEL methodSel = nil; Method *methods = class_copyMethodList([UISwitch class], &count); i = 0; while(i < count) { SEL s = method_getName(methods[i]); if (0 == strcmp(sel_getName(s), methodNameUTF8String)) { methodSel = s; i = count; } }
- Call the function for the corresponding object (testSwitch):
if (methodSel != nil) { IMP m_imp = method_getImplementation(methodsList[i]); m_imp(theSwitch, methodSel, YES); } free(methods);
Voila, we went around this limitation, but please, before using this method, think about why Apple blocked it.
PS: You can use the
App Scanner application to test the application for use by private api