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 

https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/classes/nsstring_class/index.html#//apple_ref/occ/instm/nsstring/pathextension


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -