防止NSTimer和调用对象之间的循环引用
生活随笔
收集整理的這篇文章主要介紹了
防止NSTimer和调用对象之间的循环引用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
防止NSTimer和調(diào)用對(duì)象之間的循環(huán)引用
@interface NSTimer (EOCBlocksSupport)+ (NSTimer *)eoc_scheduledTimerWithTimeInterval:(NSTimeInterval)intervalblock:(void(^)())blockrepeats:(BOOL)repeats;@end@implementation NSTimer (EOCBlocksSupport)+ (NSTimer *)eoc_scheduledTimerWithTimeInterval:(NSTimeInterval)intervalblock:(void(^)())blockrepeats:(BOOL)repeats {return [self scheduledTimerWithTimeInterval:intervaltarget:selfselector:@selector(eoc_blockInvoke:)userInfo:[block copy]repeats:repeats]; }+ (void)eoc_blockInvoke:(NSTimer*)timer {void (^block)() = timer.userInfo;if (block) {block();} }版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。
轉(zhuǎn)載于:https://www.cnblogs.com/zsw-1993/p/4879442.html
總結(jié)
以上是生活随笔為你收集整理的防止NSTimer和调用对象之间的循环引用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 也谈跨域数据交互解决方案
- 下一篇: android intent 5.1