美文网首页
四十三、内存管理之(一)NSProxy

四十三、内存管理之(一)NSProxy

作者: yqc5521 | 来源:发表于2019-05-13 20:24 被阅读0次
    @interface MJProxy : NSProxy
    +(instancetype)proxyWithTarget:(id)target;
    @property (nonatomic,weak) id target;
    
    @end
    
    #import "MJProxy.h"
    
    @implementation MJProxy
    + (instancetype)proxyWithTarget:(id)target{
        MJProxy *proxy = [MJProxy alloc];
        proxy.target = target;
        return proxy;
    }
    
    - (NSMethodSignature *)methodSignatureForSelector:(SEL)sel{
        return [self.target methodSignatureForSelector:sel];
    }
    
    - (void)forwardInvocation:(NSInvocation *)invocation{
        [invocation invokeWithTarget:self.target];
    }
    @end
    

    相关文章

      网友评论

          本文标题:四十三、内存管理之(一)NSProxy

          本文链接:https://www.haomeiwen.com/subject/duaraqtx.html