在MRC中使用弱委托是否安全?

时间:2016-12-05 02:36:36

标签: objective-c memory-management delegates

var mySubstitute = Substitute.For<IMySubstitute>();

mySubstitute.DoSomething(Arg.Any<bool>(), Arg.Any<string>())
    .Returns(new TestObject(default(string), default(bool), aValueIWantToControle));

我有一个MRC objective-c文件,它声明了一个弱委托,

Message *m = [msg retain];
dispatch_queue_t queue = _handle_queue;
__block id delegate = self.protocol_delegate;
dispatch_async(queue, ^{
    if (delegate && [delegate respondsToSelector:@selector(onReceive:)]) {
        [delegate onReceive:m];
    }
});

如果委托被释放,委托是否会重置为nil?

0 个答案:

没有答案