KSYWeakProxy Class Reference

Inherits from NSProxy
Declared in KSYWeakProxy.h

Overview

A proxy used to hold a weak object. It can be used to avoid retain cycles, such as the target in NSTimer or CADisplayLink.

sample code:

 @implementation ViewController {
    NSTimer *_timer;
 }

 - (void)initTimer {
    KSYWeakProxy *proxy = [KSYWeakProxy proxyWithTarget:self];
    _timer = [NSTimer timerWithTimeInterval:0.1 target:proxy selector:@selector(tick:) userInfo:nil repeats:YES];
 }

 - (void)tick:(NSTimer *)timer {...}
 @end

  target

The proxy target.

@property (nullable, nonatomic, weak, readonly) id target

Declared In

KSYWeakProxy.h

– initWithTarget:

Creates a new weak proxy for target.

- (instancetype)initWithTarget:(id)target

Parameters

target

Target object.

Return Value

A new proxy object.

Declared In

KSYWeakProxy.h

+ proxyWithTarget:

Creates a new weak proxy for target.

+ (instancetype)proxyWithTarget:(id)target

Parameters

target

Target object.

Return Value

A new proxy object.

Declared In

KSYWeakProxy.h