title: Problem with NSObject init method
body: <p>I have a problem with the init() method of a standard NSObject. I wrote a class (EFAPersistence) which is a subclass of NSObject. EFAPersistance has a attribute called <strong>efaDatabase</strong>.</p>
  
  <p><strong>EFAPersistence.h</strong></p>
  
  <pre><code>@interface EFAPersistence : NSObject {
    FMDatabase * efaDatabase;
  }
  
  @property (assign) FMDatabase * efaDatabase;
  </code></pre>
  
  <p>Everytime an instance of EFAPersistance is created I want to assign efaDatabase a value from my AppDelegate.</p>
  
  <p><strong>EFAPersistence.m</strong></p>
  
  <pre><code>@implementation EFAPersistence
  
  @synthesize efaDatabase;
  
  - (id)init {
    if (self = [super init]) {
      efaDatabase = [[NSApp delegate] efaDatabase];
    }
    return self;
  }
  
  @end
  </code></pre>
  
  <p>This way of assigning does not work. But it works if I put the code in a normal method. So I am sure that efaDatabase is correctly instantiated in my AppDelegate. It's just not working in my init() method. That's why I have the feeling that NSApp is not working inside the init() method.</p>
  
  <p>That's how the important AppDelegate code looks like.</p>
  
  <p><strong>AppDelegate.h</strong></p>
  
  <pre><code>@interface AppDelegate : NSObject &lt;NSApplicationDelegate&gt; {
    FMDatabase * efaDatabase;
  }
  </code></pre>
  
  <p><strong>AppDelegate.m</strong></p>
  
  <pre><code>- (id)init {
    if (self = [super init]) {
      NSString * databasePath = 
        [[NSBundle mainBundle] pathForResource:@"efa" ofType:@"sqlite"];
  
      self.efaDatabase = [FMDatabase databaseWithPath:databasePath];
  
      if (![efaDatabase open]) {
        NSLog(@"Couldn't open database: %@", databasePath);
        // TODO: Create a database here
      }
      self.db = [[EFAPersistence alloc] init];
    }
    return self;
  }
  </code></pre>
  
  <p>As you can see I am calling the init method. I also affirmed this by using NSLog(). init() is called. The attribute I am trying to assign in EFAPersistence is also created before init() is called.</p>
  
  <p>To sum everything up:</p>
  
  <p>How can I make this work within the init() method so I do not have to write boiler plate code in all my methods of EFAPersistence?</p>