1、NSProxy
@implementation FirViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor orangeColor];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:(UIBarButtonItemStylePlain) target:self action:@selector(back)];
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:[[WeakProxy alloc] initWithTarget:self] selector:@selector(action:) userInfo:nil repeats:YES];
}
- (void)back
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)dealloc
{
[self.timer invalidate];
self.timer = nil;
NSLog(@"=== dealloc");
}
- (void)action:(id)sender
{
NSLog(@"====== %@",[NSDate date]);
}
@end
@implementation WeakProxy
{
__weak id _target;
}
- (WeakProxy*)initWithTarget:(id)targe