Лучший способ (или, по крайней мере, альтернатива в Swift 2.0) - использовать свойство String pathComponents. Это разделяет путь в массив строк. например
if let pathComponents = filePath.pathComponents {
if let last = pathComponents.last {
print(" The last component is \(last)") // This would be the extension
// Getting the last but one component is a bit harder
// Note the edge case of a string with no delimiters!
}
}
// Otherwise you're out of luck, this wasn't a path name!