objective c get or remove file extension from path
Posted by Eng.Ahmed AlSadiOct 7
xcode – iPhone – Objective c
if you have file path and want to get file extension you can use [NSString : pathExtension] “Interprets the receiver as a path and returns the receiver’s extension, if any.” , “myFile.txt” will return “txt”
|
1 2 |
//get Path extension - alsadi
NSString* extension = [@"myFile.txt" pathExtension]; |
and if you want to delete file extension and get only file name “myFile.txt” will be “myFile” , you can use [NSString : stringByDeletingPathExtension] “Returns a new string made by deleting the extension (if any, and only the last) from the receiver.”
|
1 2 |
//delete path or file extension - alsadi
NSString* fileName = [@"myFile.txt" stringByDeletingPathExtension]; |
Related posts:
- objective c get iTunes file sharing folder files with full path xcode – iphone – objective c Hi; the method “function” below show you how to...
- Objective-c NSFileHandle get file size XCode – Objective-c Hi, If you use NSFileHandle in your code and you need to...
- objective c documents and temp directory Xcode – Objective-c Hi, If you want to get path of documents directory , you...
- objective c iOS sqlite3 tutorial with source code sample Xcode – objective-c -iphone source code; Hi, iPhone iOS embedded sqlite3 , first thing you...
- Objective-c check if file exists XCode – Objective-C Hi, The simplest way to know or to check if file exists...
Leave a Reply