On Aug 14, 2016, at 20:08 , Ben Kennedy <b...@zygoat.ca> wrote:
> 
> 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'

You’re correct, the SDK had been changed in 10.11, which I hadn’t noticed. 
However, in the second form, the receiver is (I would say) *clearly* exhibiting 
the old behavior**. This may or may not be by intention. In several places I 
found by searching the __kindof is described as being somewhat “like" ‘id’. For 
example, in the Xcode 7 release notes:

> "Objects declared as __kindof types behave like a mix of id and a specific 
> object type: They specify an upper bound (for example, must be UIView or a 
> subclass thereof) but allow implicit downcasting to any subtype of that upper 
> bound.”


I guess this should at least be reported as a bug.


** Indeed, it might be exhibiting the old behavior in the first case, too, with 
the fact that it chose a NSApplication method being a random accident.

 _______________________________________________
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