There’s some way to test for an objective-c instance for being dealloced/freed (retain count == 0)??
By example, object A have a reference (pointer) to object B, but object B can be freed in memory low levels, how i test reference B to be sure it was dealloced??
@interface A : NSObject {
B b;
}
@implementation A {
- (void) someAction:(id) sender {
//is b previously dealloced??
if ..... ???? {
b = [[B alloc] init];
}
// continue
}
}
Thanks!!
You can’t test whether an object has been dealloced since, obviously, the object isn’t there to talk to anymore. If you set
bto nil when you release it (say, by doingself.b = nil), though, you can test for nil and create the object then.