Get the extension of a file contained in an NSString

前端 未结 6 1941
[愿得一人]
[愿得一人] 2020-12-08 13:25

I have an NSMutable dictionary that contains file IDs and their filename+extension in the simple form of fileone.doc or filetwo.pdf. I need to determine what type of file it

6条回答
  •  囚心锁ツ
    2020-12-08 13:35

    Try this, it works for me.

    NSString *fileName = @"yourFileName.pdf";
    NSString *ext = [fileName pathExtension];
    

    Documentation here for NSString pathExtension

提交回复
热议问题