How to get the filename from the filepath in swift

后端 未结 10 1512
一生所求
一生所求 2020-12-04 20:47

How to get the filename from the given file path string?

For example if I have a filepath string as

file:///Users/DeveloperTeam/Library/Developer/Co         


        
10条回答
  •  天命终不由人
    2020-12-04 21:27

    Objective C

    NSString* theFileName = [string lastPathComponent]
    

    Swift

    let theFileName = (string as NSString).lastPathComponent
    

提交回复
热议问题