I'm trying to convert a path extension to lowercase in swift. This should be fairly easy, but when I use the obvious code, I keep getting an error:
var filePath = "/path/to/file.CSV"
var fileExtension = filePath.pathExtension
fileExtension.lowercaseString //ERROR happens when I try to convert to lowercase
execution failed: error: Execution was interrupted, reason:
EXC_BAD_ACCESS (code=1, address=0x0).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression
* thread #1: tid = 0x231209, 0x00000001083083a6, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
* frame #0: 0x00000001083083a6
This is a bug for me as well, one work around is to cast the String to
var filePath = "/path/to/file.CSV" var fileExtension = filePath.pathExtension (fileExtension as NSString).lowercaseString