Re: How to do isKindOfClass in Swift

2016-09-12 Thread Gerriet M. Denkmann
> On 13 Sep 2016, at 00:14, Quincey Morris > wrote: > > On Sep 12, 2016, at 03:17 , Gerriet M. Denkmann wrote: >> >> The I got back to the real project: and could also not reproduce it there. >> >> One explanation: working with Swift, I quite often (a few times per day) see >> strange (runt

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 12:57 , Greg Parker wrote: > > Did you file a bug report? It’s a little awkward. The case I ran into was one of those breakpoint instruction crashes that I think the compiler inserts when it wants to crash deliberately, such as a fatalError() call, but the backtrace was lyi

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Greg Parker
> On Sep 12, 2016, at 10:14 AM, Quincey Morris > wrote: > >> On Sep 12, 2016, at 03:17 , Gerriet M. Denkmann wrote: >> >> The I got back to the real project: and could also not reproduce it there. >> >> One explanation: working with Swift, I quite often (a few times per day) see >> strange

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 10:27 , Jens Alfke wrote: > > At least it doesn’t catch fire, does it? I wouldn’t rule that out. I’m not much of an alarmist, but for anyone using Swift that hasn’t moved to Xcode 8 yet, I’d suggest holding off for a week or two to see if there’s any kind of emergency patc

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Jens Alfke
> On Sep 12, 2016, at 10:14 AM, Quincey Morris > wrote: > > FWIW, it’s pretty clear that the version of Swift in the Xcode 8 GM is > generating incorrect code or incorrect debug information Well, that’s comforting to hear. O_o At least it doesn’t catch fire, does it? —Jens _

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 03:17 , Gerriet M. Denkmann wrote: > > The I got back to the real project: and could also not reproduce it there. > > One explanation: working with Swift, I quite often (a few times per day) see > strange (runtime) errors. Cleaning the project, then building again > invaria

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Gerriet M. Denkmann
> On 12 Sep 2016, at 15:51, Quincey Morris > wrote: > > On Sep 12, 2016, at 01:32 , Gerriet M. Denkmann wrote: >> >> In my real (as opposed to playground) code, each class lives in a different >> file. > > I just tried it with classes in different files, and no compile error. I > don’t thi

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 01:32 , Gerriet M. Denkmann wrote: > > In my real (as opposed to playground) code, each class lives in a different > file. I just tried it with classes in different files, and no compile error. I don’t think this is a Swift 2 thing, because the “is” has been around since th

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Gerriet M. Denkmann
> On 12 Sep 2016, at 15:10, Quincey Morris > wrote: > > On Sep 12, 2016, at 01:00 , Gerriet M. Denkmann wrote: >> >> 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:

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 01:00 , Gerriet M. Denkmann wrote: > > 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

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Gerriet M. Denkmann
> On 12 Sep 2016, at 14:55, Quincey Morris > wrote: > > On Sep 12, 2016, at 00:50 , Gerriet M. Denkmann 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. T

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 00:50 , Gerriet M. Denkmann 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. ___

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Gerriet M. Denkmann
> On 12 Sep 2016, at 14:27, Quincey Morris > wrote: > > On Sep 12, 2016, at 00:08 , Gerriet M. Denkmann wrote: >> >> I want to do: >> if self.dynamicType == SomeClass { … } >> >> But the compiler won’t accept this (or any number of variations thereof). > > Try this: > > if self is So

Re: How to do isKindOfClass in Swift

2016-09-12 Thread Quincey Morris
On Sep 12, 2016, at 00:08 , Gerriet M. Denkmann wrote: > > I want to do: > if self.dynamicType == SomeClass { … } > > But the compiler won’t accept this (or any number of variations thereof). Try this: if self is SomeClass { … } Typically, if you need to use a class in an expression,

How to do isKindOfClass in Swift

2016-09-12 Thread Gerriet M. Denkmann
I have a pure Swift class. I want to do: if self.dynamicType == SomeClass { … } But the compiler won’t accept this (or any number of variations thereof). isKindOfClass needs a “class object representing the Objective-C class to be tested”. How can this be done? Gerriet. _