-(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];
}
});
}
NSValue *value = [NSValue valueWithNonretainedObjectValue:myObj];
[array addObject:value];
and when you get the object:
value = [array objectAtIndex:x];
myObj = [value nonretainedObjectValue];
网友评论