在ARC下使用
1 |
[theTarget performSelector:theTarget withObject:Nil]; |
会出现警告:performselector-may-cause-a-leak-because-its-selector-is-unknown
解决方法:
1:添加如下宏
1 |
#define SuppressPerformSelectorLeakWarning(Stuff) \ |
3 |
_Pragma( "clang diagnostic push" ) \
|
4 |
_Pragma( "clang diagnostic ignored \"-Warc-performSelector-leaks\"" ) \
|
6 |
_Pragma( "clang diagnostic pop" ) \
|
2:使用宏
1 |
SuppressPerformSelectorLeakWarning([theTarget performSelector:theAction withObject:@ "hello" ]);
|
参考:http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown
分享到:
相关推荐
OC-performSelector
swift并没有提供performSelector ,我伪代码写了一个扩展类。使用时请小心。详见我博文说明。http://blog.csdn.net/fengsh998/article/details/35842441
ios demo,performSelector和respondsToSelector,动态添加方法,多参数调用
[self performSelector:@selector(lazyButtontouchDown) withObject:nil afterDelay:self.minimumPressDuration]; } -(void)lazyButtontouchDown { } //当离开按钮的时候取消所调用的方法 - (void)...
[self performSelector:@selector(machineBallAction) withObject:nil afterDelay:0]; 3.实现随机数:srandom(time(NULL)); 4. #pragma mark - #pragma mark Initialization 它们告诉Xcode编译器,要在...
前言 在开发过程中,我们有时会希望把一些操作封装起来延迟一段时间后再执行。本文列举了四种延时执行某函数的方法及其一些区别。假如延时1秒时间执行下面的方法。... [self performSelector:@selector(delayD
[self performSelector:@selector(selectPic:) withObject:imageafterDelay:0.1]; } -(void)selectPic:(UIImage*)image { NSLog(@"image%@",image); imageView = [[UIImageView alloc] initWithImage:image]; ...
[self performSelector:@selector(toggle:) withObject:btCont afterDelay:1.0f] ; #endif } #if TARGET_IPHONE_SIMULATOR #else - (void)toggle:(id)btCont { BOOL currentState = [btCont enabled] ; [btCont ...
performSelector:withObject:方法的作用是什么? 解释一下多态 如何实现深拷贝 http和socket通信的区别,tcp和udp的区别,session和cookie的区别 block实现原理 响应链 frame 和 bounds 写一个宏MIN,这个宏输入两个...
_vi.backgroundColor=[UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1]; 屏幕触发事件 -(void)touchesBegan:(NSSet *)touches withEvent:(UI...
- (void)playAnimateWithName:(NSString *)name framesNumber:(int)frames {... [self.imageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.imageView.animationDuration]; }
[keyWindow performSelector:@selector(startIndicatingTouches)];通过在应用程序委托的 -applicationWillResignActive: 方法末尾调用以下代码来停用触摸指示器也是一个好主意。 UIWindow *keyWindow = [[UI
另外想用同样的方式解决消息调用找不到selector时crash的问题,替换performSelector,但是不知道啥,注释的地方异常访问,哪位大大知道请赐教。 - (id)SKperformSelector:(SEL)aSelector{ if ([self ...
[(NSObject*)self performSelector:@selector(request:didUpdateStatus:) withObject:self withObject:status]; 应该是 [(NSObject*)self.delegate performSelector:@selector(request:didUpdateStatus:) with...
近日学习了延迟执行的几种方法,分享一下。 1.performSelector(NSObject)方法 2.NSTimer方法 3.GCD方法 4.sleep(NSThread)方法 延迟执行代码: ...[self performSelector:@selector(delayDo:
来源:github/DurexKitLicence:Apache 2.0作者:CUSLayout 解决iOS因原生方法抛出的异常引起的程序闪退问题。... 2、解决NSObject performSelector找不到selector引起的闪退。 开发者说:希望大家一
NSInvocation的作用和performSelector:withObject:的作用是一样的:用于iOS编程中调用某个对象的消息。 performSelector:withObject:调用一些参数较少的消息是比较方便的,但是对于参数个数大于2的消息,使用...
LRVariadicPerformSelector 因为有时候,我们需要使用两个以上的参数来执行选择器... 同样,这个简单的类别允许选择注入我们要在其上执行选择器的队列( ...用法[self lr_performSelector:@selector(because:sometimes:
代码如下:[self performSelector:@selector(delayMethod) withObject:nil afterDelay:1.0f]; 1.特点: 此方式要求必须在主线程中执行,否则无效。 是一种非阻塞的执行方式, 暂时未找到取消执行的方法。 二、定时器:...
数据加载完成后消失[self performSelector:@selector(dis) withObject:self afterDelay:4]; //4秒后消失,也就是数据加载完成后执行-(void)dis{ [ZFYLoading dismiss]; }###没有数据 没有数据1 [ZFYLoading ...