typedef void (^dd)(void);
@property (strong) dd a ;
@property (copy) dd a ;
__weak id b=self;
self.a=^{
NSLog(@"%@",self);
};
编译器都会有警告:循环引用造成的内存泄露
---------------------------------------------------
CFMutableArrayRef cfObject = NULL;
{
id obj = [[NSMutableArray alloc] init];
cfObject = (__bridge_retained CFMutableArrayRef)obj;
NSLog(@"%lo ng-",CFGetRetainCount(cfObject));
//__weak id oo=obj;
void (^dd)(void)=^{
NSLog(@"%@",obj);
};
//dd();
NSLog(@"%lo ng---",CFGetRetainCount(cfObject));
//CFRelease(cfObject);
}
NSLog(@"%lo ng---",CFGetRetainCount(cfObject));
被block捕获的变量都会被retain.
block,__bridge_retained代码试例,布布扣,bubuko.com
时间: 2024-10-10 00:13:33