The beginning of the wording:
SEL Selctor = nsselectorfromstring (_interaction. functionname );
[selfperformselector: selctor withobject: nil];
Workaround:
Compiler warning This is caused by the reason that this warning is rare, even simple to ignore, and easy to solve. Here's how:
SEL Selctor = nsselectorfromstring (_interaction. functionname );
IMP imp = [selfmethodforselector: selctor];
void ( *func) (ID,SEL) = (void *) imp;
func (self, selctor);
the reason for the resolution :
If you call a method name, you must have a corresponding method. You can use Class_getmethodimplementation (for example, a protocol id<someproto>) at run time. You only need to define (ID (*imp ) (ID, SEL, ...)) These function pointers can be called by the Imp. This may be closest to the actual signature of the method, but does not match exactly. The IMP is defined, and you need to assign it to a function pointer that contains all of the parameters required by the arc (including the implicit arguments self and _cmd, which are called by all 2 OC methods). The third line to the right (void *) just tells the compiler I know what I'm going to do, don't give me an error when the pointer doesn't match. The last line is to call your function pointer.
warning Cause :
in ARC, the runtime needs to know the execution result of this method. The result may be void int Char NSString *, ID, etc. arc typically gets the type of object you are manipulating from the declaration (releasing objects that are not in use).
consider the ARC in the 4 kind of return value
1. Ignore non-object types (Void,int, etc.)
2. Reture object, when not in use will release
3. When a new object is no longer in use, release
4. The return value of the object is valid in the local scope (ns_return_autoreleased will be released when the innermost release pool is released)
the Methodforselector : the call , Suppose that this method is called by an object with a return value , but not retain or Release out of it. If it is a third-party situation, it can cause a memory leak.
for methods that do not return values or return values of non-objects, you can use compiler attributes to ignore this warning, but this can be dangerous. So even if you don't want to use it, the compiler will retain or release it. From the compiler's point of view , This is after all an object , This means that you call the method and return a non-object type (including void), which may cause a garbage pointer to be retain or release. This causes a crash.
IOS Performselector may cause a leak because it selector is unknown