self.appDelegate = [[UIApplication sharedApplication] delegate]; ALWAYS 0x0
<p>I am experiencing a strange behaviour.
In a view controller I would like to keep a reference on my app delegate (<code>[[UIApplication sharedApplication] delegate]</code>)</p>

<p>So I have a property I set when my controller is instantiated.
All is working on the simulator by on the device my property is always 0x0 in debugger.</p>

<p>I wrote this code to test :</p>

<pre>
<code>
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {       
        AppDelegate *localVar = [[UIApplication sharedApplication] delegate]; // OK
        self.appDelegate = [[UIApplication sharedApplication] delegate]; // 0x0
    }
    return self;
}
</code>
</pre>

<p>I am sure that the appDelegate is set, I also write a setter to verify that it is called</p>

<pre>
<code>
- (void)setAppDelegate:(AppDelegate *)delegate
{
    appDelegate =  delegate; // delegate is a valid address but appDelegate is still showing 0x0
}
</code>
</pre>

<p>I am wondering if my AppDelegate class is well written.</p>

<p>Do you have an idea ?</p>

<p>I am lost...</p>

<p>Thanks</p>
