0

I know your initial thought is that this is a duplicate. I have looked into all the duplicate questions, popular one being How do I print the type or class of a variable in Swift? But it didn't seem to help.

I have defined an array like this var stringArray = ["this","is","string","array"]

I tried println("\(object_getClassName(stringArray))") which is the chosen answer in the above specified post. But that results in Xcode going into some loop of showing this error

SourceKit service terminated. Editor functionality temporarily limited.

enter image description here

This seems to be a known reported bug which seems to occur in various scenario's.

I tried stringArray.className and stringArray.dynamicType.description(). I get a compiler error saying those properties are not defined.

Any directions would be appreciated.

Community
  • 1
  • 1
Adithya
  • 4,385
  • 3
  • 24
  • 28
  • The `SourceKitService Terminated` only tells you that syntax highliting is currently unavailable in Xcode’s editor, because it crashed. That is unrelated to you original question, which is a dupe. – Palimondo Jun 16 '14 at 09:57
  • @Fogmeister From the linked post, I see I have to use something like stringArray.dynamicType.className() to get the type. But it doesn't seem to work. I'm not sure how this is duplicate of that. – Adithya Jun 16 '14 at 10:37
  • I guess that has to do something with Array being a `struct`… not a `class`. Generally Swift currently does not have introspection or any officially supported reflection capabilities. – Palimondo Jun 16 '14 at 11:03
  • @Palimondo Agree on that. – Adithya Jun 16 '14 at 11:07
  • http://stackoverflow.com/q/24006206/2446155 – Andrew Jun 18 '14 at 17:17

0 Answers0