performSelector may cause a leak because its selector is unknown

后端 未结 19 2250
小蘑菇
小蘑菇 2020-11-22 01:54

I\'m getting the following warning by the ARC compiler:

\"performSelector may cause a leak because its selector is unknown\".

Here\'s what

19条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 02:52

    Strange but true: if acceptable (i.e. result is void and you don't mind letting the runloop cycle once), add a delay, even if this is zero:

    [_controller performSelector:NSSelectorFromString(@"someMethod")
        withObject:nil
        afterDelay:0];
    

    This removes the warning, presumably because it reassures the compiler that no object can be returned and somehow mismanaged.

提交回复
热议问题