I’m new at OS X development, I’ve been having a problem getting a delegate callback and I somehow suspect that it might be a memory problem. I have an NSViewController. In it’s init method I am setting up a custom NSObject as so:
MyObject *aManager = [[MyObject alloc] initManager];
__theManager = aManager;
self.theManager.delegate = self;
[aManager release];
the delegate I’ve setup as nonatomic, assign. Looking at the breakpoints I should be seeing the callback in my view controller but this never happens. Any ideas?
__theManager = aManager;should beself.theManager = aManager;, assumingtheManageris a retained property. The problem you have is thatalloc] init];givesaManagera retain count of +1.__theManager = aManager;does not increase that count, as the iVar is set directly. When you release it, the retain count becomes 0, and so it is deallocated.