iOS如何存储多个delegate

可以使用NSHashTable存储weak指针

NSObject *obj = [[NSObject alloc] init];
__weak NSObject *weakobj1 = obj;
NSHashTable *table = [NSHashTable weakObjectsHashTable];
 [table addObject:weakobj1];
image.png
NSObject *obj = [[NSObject alloc] init];
__weak NSObject *weakobj1 = obj;
NSHashTable *table = [NSHashTable weakObjectsHashTable];
 [table addObject:weakobj1];
weakobj1 = nil;
 obj = nil;
image.png

你可能感兴趣的:(iOS如何存储多个delegate)