On 13 Aug 2016, at 2:52 pm, Quincey Morris 
<quinceymor...@rivergatesoftware.com> wrote:

> 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.

Are you sure that's still the case? While I'm admittedly running 10.12 beta on 
this machine as I type, I've nonetheless launched Xcode 7.3.1 and created a 
test project using the 10.11 SDK.

In NSApplication.h, NSApp and the delegate property are declared as follows:

> APPKIT_EXTERN __kindof NSApplication * __null_unspecified NSApp;
> …
> @property (nullable, assign) id<NSApplicationDelegate> delegate;

When I attempt to assign a delegate after deleting the implementing class's 
conformance to NSApplicationDelegate (such that it simply descends from 
NSObject), these two semantically-equivalent calls yield different errors 
messages:

> NSApp.delegate = self;
> // Assigning to 'id<NSApplicationDelegate> _Nullable' from incompatible tyoe 
> 'AppDelegate *const __strong
> 
> [NSApp setDelegate:self];
> // Sending 'AppDelegate *const __strong' to parameter of incompatible type 
> 'id<NSFileManagerDelegate> _Nullable'


However, both are resolved by declaring the app delegate to conform to 
NSApplicationDelegate (as is does in the default project template).

Thus a question for Dale: does your delegate declare conformance to the 
protocol?

b


 _______________________________________________
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