How to catch an error on SCNReferenceNode.referenceURL property (SceneKit)?

The problem is that if I create SCNReferenceNode and try to get referenceURL

...
        let refNode: SCNReferenceNode = SCNReferenceNode()
        let curUrl = refNode.referenceURL
...

in order to check if it is nil, I got an exception

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x186d06dd0)

And looks like there is no way to work around this.

P.S. I know there is an option to give an URL to the constructor like SCNReferenceNode(myURL), but I have to use an approach where I create SCNReferenceNode before then refURL is available.

Replies

in order to check if it is nil, I got an exception

How do you make the check ?

Did you try:

if let curUrl = refNode?.referenceURL {
  print("Not nil")
} else {
  print("Nil")
  • "How do you make the check ?" - I described in the question how to check, it is very simple, just try to create this object SCNReferenceNode and the next line try to get referenceURL, what is the result you get?

Add a Comment