Reputation: 1132
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?
Upvotes: 0
Views: 393
Reputation: 8526
__theManager = aManager;
should be self.theManager = aManager;
, assuming theManager
is a retained property. The problem you have is that alloc] init];
gives aManager
a 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.
Upvotes: 2