Eric Boumendil Eric Boumendil - 10 months ago 85
Swift Question

Why SKProductsRequestDelegate/SKRequestDelegate didFailWithError throws EXC_BAD_ACCESS on NSError?

I use

to download product infos from App Store.
When I test a connectivity loss on my device, the request fails, but my app crashes within the
when I try to
the error:


What am I doing wrong ? Another curious thing to me is that Expression Inspector is able to display

It fails on the first request, so there is no possible bug relative to multiple uses of productRequest variable (which is a strong ref in my swift class).


I finally found the reason. It is not related to SKProductsRequest!

I think there is a nasty bug with NSLogand string interpolation because when I replace:

NSLog("Failed: \(error.debugDescription)")


print("Failed: \(error.debugDescription)")

all is fine!

Apparently, the content of the error message can provoke a EXC_BAD_ADDRESS in NSLog (even without string interpolation in fact: NSLog(error.debugDescription) fails too).