美文网首页
iOS如何存储多个delegate

iOS如何存储多个delegate

作者: 哈哈哈我的简书账号 | 来源:发表于2021-05-24 22:42 被阅读0次

可以使用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

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