How to get the filename from the filepath in swift

后端 未结 10 1527
一生所求
一生所求 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:28

    If you want to get the current file name such as for logging purposes, I use this.

    Swift 4

    URL(fileURLWithPath: #file).lastPathComponent
    

提交回复
热议问题