如何以正确的方式向由属性强制定义的NSMutableArray中添加对象。
[tapBlockView setTapBlock:^(UIImage* image) {
[self.myImageArray addObject:image]; // self retain cycle
}
如果我想创建弱引用,就像这样:
__weak NSMutableArray *array = self.myImageArray;
[tapBlockView setTapBlock:^(UIImage* image) { [array addObject:image]; // If I will do this then how will I update original Array ?
}
我也尝试过
__weak id weakSelf = self;
[tapBlockView setTapBlock:^(UIImage* image) {
[weakSelf storeImageInaNewMethod:image]; // Calling SToreImageInaNewMethod
}
和
-(void)storeImageInaNewMethod:(UIImage*)image {
[self.myImageArray addObject:image]; // This again retaining cycle
}
如何正确更新由属性定义的原始对象?