0

Okay, I really use autorelease/asign lots but I got a problem right now that I don't get. It's probably quite obvious why it isn't working but I'd really like you to explain it to me.

So I've got a UIViewController that I initialize like that:

controller = [[[LBLogInViewController alloc] initWithNibName:@"LBLogInViewController" bundle:nil] autorelease];

Afterwards, I set it a property (nonatomic, assign) :

controller.settingsViewController = self;

Why does that property not last? The value I set is the superview's controller so it won't be released. It obviously works with (nonatomic, retain) but I'd like to know why assign doesn't work here.

4

2 回答 2

0

If controller is declared as (nonatomic, retain) and you use "controller =" instead of "self.controller =", you will not be incrementing the retain count because you are bypassing the setter and going straight to the instance variable.

于 2011-11-07T02:23:08.860 回答
0

检查您的@synthesize、@property 和 settingsViewController ivar 是否没有拼写错误(完全相同)。

于 2011-11-07T02:07:36.003 回答