I have an object with a property that points to a block:
typedef void (^ThingSetter)();
@property(nonatomic, strong) ThingSetter setup;
I initialize the property with a block. Within the block I refer to the object instance:
Thing *thing = [[Thing alloc] init];
thing.setup = ^() {
plainOleCFunction(thing.number);
[thing doSomethingWithString:@"foobar"];
};
However I get compile warnings about a retain loop:
capturing 'thing' strongly in this block is likely to lead to a retain cycle
block will be retained by the captured object
What is the correct way to do this?
Thanks,
Doug
you have to assign
thingas weak ref:or you could provide
thingas Parameter to the block: