美文网首页
iOS多播委托:XMPP中的GCDMultiCaseDelega

iOS多播委托:XMPP中的GCDMultiCaseDelega

作者: Noonday | 来源:发表于2016-07-06 17:24 被阅读79次

    -(void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)queue

    {

    if(!_managerDelegates) {

    _managerDelegates= [[NSMutableArrayalloc]init];

    }

    if(!queue) {

    queue =dispatch_get_main_queue();

    }

    dispatch_async(queue, ^{

    if(![_managerDelegatescontainsObject:delegate])

    {

    NSValue*value = [NSValuevalueWithNonretainedObject:delegate];

    [_managerDelegatesaddObject:value];

    }

    });

    }

    weak引用NSArray的实现

    NSValue *value = [NSValue valueWithNonretainedObjectValue:myObj];

    [array addObject:value];

    and when you get the object:

    value = [array objectAtIndex:x];

    myObj = [value nonretainedObjectValue];

    相关文章

      网友评论

          本文标题:iOS多播委托:XMPP中的GCDMultiCaseDelega

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