I currently have a string containing a path to an image file like so:
/Users/user/Library/Developer/CoreSimulator/Devices/Hidden/data/Containers/Data/Application
Try this :
1)
var str = "/Users/user/Library/Developer/CoreSimulator/Devices/Hidden/data/Containers/Data/Application/Hidden/Documents/AppName/2017-07-07_21:14:52_0.jpeg"
let array = str.components(separatedBy: "/")
print(array[array.count-1]) //2017-07-07_21:14:52_0.jpeg
2)
let str = "/Users/user/Library/Developer/CoreSimulator/Devices/Hidden/data/Containers/Data/Application/Hidden/Documents/AppName/2017-07-07_21:14:52_0.jpeg"
var fileName = URL(fileURLWithPath: str).lastPathComponent
print(fileName) //2017-07-07_21:14:52_0.jpeg
let fileName = URL(fileURLWithPath: path).deletingPathExtension().lastPathComponent
print(fileName) //2017-07-07_21:14:52_0