• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Warning from Xcode build
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warning from Xcode build


  • Subject: Re: Warning from Xcode build
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 13 Aug 2016 14:52:21 -0700
  • Feedback-id: 167118m:167118agrif8a:167118s4Y5oYa_0x:SMTPCORP

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 <email@hidden> 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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Warning from Xcode build
      • From: Ben Kennedy <email@hidden>
References: 
 >Warning from Xcode build (From: Dale Miller <email@hidden>)

  • Prev by Date: Warning from Xcode build
  • Next by Date: Re: Warning from Xcode build
  • Previous by thread: Warning from Xcode build
  • Next by thread: Re: Warning from Xcode build
  • Index(es):
    • Date
    • Thread