Dr.Kameleon
Dr.Kameleon

Reputation: 22820

Instance method not found - for App Delegate property

OK, here's my situation...

My App Delegate is declared as follows :

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (assign) ppDocumentManager* documentManager;

Now, from a different location I'm trying to access documentManager, like this :

AppDelegate* de = (AppDelegate*)[[NSApplication sharedApplication] delegate]; 
ppDocumentManager* docs = [de documentManager];

And, at the top of the file, I've also added @class AppDelegate; so that the compiler knows what AppDelegate stands for.

And it works fine.


However, I keep getting warnings :

Instance method '-documentManager' not found (return type defaults to 'id')

What should I do in order to eliminate all the warnings?

Upvotes: 1

Views: 736

Answers (2)

user2346927
user2346927

Reputation: 1

I had the same issue and I found out it came from having the appdelegate named "AppDelegate" and not some custom name like "MyAppDelegate".

Rename my class to "MyAppDelegate" and the import to "MyAppDelegate.h" made the trick.

Upvotes: 0

Dr.Kameleon
Dr.Kameleon

Reputation: 22820

OK, this is what worked for me :

  • I had decided to use @class AppDelegate; at the beginning of the .m file making use of documentManager, in order to avoid the risk of circular references.

However, it turns out that wasn't necessary.

I just imported AppDelegate.h and everything comes into place.

Pheww....

Upvotes: 2

Related Questions