Re: How to do isKindOfClass in Swift
Re: How to do isKindOfClass in Swift
- Subject: Re: How to do isKindOfClass in Swift
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 12 Sep 2016 15:00:49 +0700
> On 12 Sep 2016, at 14:55, Quincey Morris <email@hidden> wrote:
>
> On Sep 12, 2016, at 00:50 , Gerriet M. Denkmann <email@hidden> wrote:
>>
>> I would much prefer to have the semantics of “isKindOf”.
>
> Yes, I know, that’s why you should be using:
>
> if self is SArray
>
> It has the semantics of isKindOf. That was what (I thought) I said.
Sorry: I wanted to follow your advice, but made a mess of it.
This is what I wanted to write:
if self is SArray { … }
But the compiler warns me: Cast from ‘SBase.Type’ to unrelated type 'SArray' always fails.
It is right: the test always fails. And wrong: they are NOT unrelated: SArray is subclass of SBase.
The test is in SBase, which has a subclass SArray, which has subclasses SArray1, SArray2, …
I am still using Swift < 3.
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden