Please help resolve Crash in guard let statement

I have a swift code that accesses an obj-C class's string property. Like this: guard let unwrappedStr = objC.str

Crash stems in the above unwrapping line. Getting -[NSNull _fastCStringContents:]: unrecognized selector sent to instance I am unable to reproduce it on my device while debugging.

CoreFoundation__exceptionPreprocess (CoreFoundation)
libobjc.A.dylibobjc_exception_throw (libobjc.A.dylib)
CoreFoundation+[NSObject(NSObject) _copyDescription] (CoreFoundation)
CoreFoundationforwarding (CoreFoundation)
CoreFoundation_CF_forwarding_prep_0 (CoreFoundation)
libswift...re.dylibspecialized withCocoaASCIIPointer(:requireStableAddress:work:) (libswiftCore.dylib)
libswift...re.dylibbridgeCocoaString(:) (libswiftCore.dylib)
libswift...re.dylibString.init(_cocoaString:) (libswiftCore.dylib)
libswift...on.dylibstatic String.unconditionallyBridgeFromObjectiveC(:) (libswiftFoundation.dylib)

The issue as far as I investigated pops up in the objC to swift bridging calls so any help is appreciated.

Please show code:

  • objC class
  • more code where the error occurs

could you add a print before guard

print("str", objC.str)

I am not able to reproduce it in my build

Please post a full crash report, per the instructions in Posting a Crash Report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Please help resolve Crash in guard let statement
 
 
Q