I have a String 11/Passion/01PassionAwakening.mp3
and I need to delete the last path component 01PassionAwakening.mp3
in order to get 11/Passion
.
How can I do this while saving both components?
You can separate your url into two parts like so:
let str : NSString = "www.music.com/Passion/PassionAwakening.mp3" let path : NSString = str.stringByDeletingLastPathComponent let ext : NSString = str.lastPathComponent print(path) print(ext)
www.music.com/Passion PassionAwakening.mp3
For more info please have a look at this link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With