ios - Determine filetype of path string in Swift -
i need decide filetype of file filename in string. decided last 3 characters of string decide filetype is. how last 3 characters in string. example
var filename = "test.pdf"
i need pdf alone. is there other better way check file type other this. please suggest me also. because think, won able recognise if filetype comes in 4 characters "jpeg" , other stuff. in advance.
i think looking :
the path extension, if any, of string interpreted path. (read-only) declaration
swift
var pathextension: string { }
discussion
the path extension portion of last path component follows final period, if there one. extension divider not included. following table illustrates effect of pathextension
on variety of different paths:
receiver’s string value
string returned
“/tmp/scratch.tiff” “tiff”
example :
file.pathextension
Comments
Post a Comment