Ha! It’s a trick being played on you by the ghost of NeXTStep.

Historically, as in 20 years ago, many things were typed ‘id’ that would now 
have a specific type. Not sure why, but global variable NSApp is one of them.

So, when you send the “setDelegate:” message to it, the Obj-C compiler doesn’t 
know what class it really is. According to its usual rule, if it can see *any* 
declarations of a “setDelegate:” method in the compilation unit, it uses 
whichever one it likes for its syntax analysis.

So, in this case, it happened to choose the NSFileManager version of 
“setDelegate:”, which requires a protocol conformance that your app delegate 
doesn’t have.

Either cast NSApp explicitly to type (NSApplication*), or use [NSApplication 
delegate], so the compiler doesn’t end up playing guessing games with your code.

> On Aug 13, 2016, at 14:42 , Dale Miller <dalelmil...@centurylink.net> wrote:
> 
> I have the following statement in the init method of my major class:
>       [NSApp setDelegate:self];
> I get the following warning from Xcode 7.3.1
>       Sending ‘UnicodeIndexBuilder’ to parameter of incompatible 
> type'id<NSFileManagerDelegate> _Nullable 
> All of the NSApplication.h files i can find on my Mac (OS X 10.11.6) read as 
> follows:
>       - (void)setDelegate:(id)anObject
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (Xcode-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to