1

I want get extension (format file from NSString) but I dont know about it please tell me syntax for getting format file from NSString.

NSString *name = @"Xcode-tutorial.pdf"

I want get .pdf format and store in one variable

david
  • 147
  • 3
  • 12

3 Answers3

7

Use NSStrings pathExtension method:

NSString *fileExtension = [name pathExtension];
HAS
  • 19,140
  • 6
  • 31
  • 53
4

Did you look in the documentation? There is a method that does just that:

NSString *ext = [name pathExtension];
NSLog(@"%@", ext);
DrummerB
  • 39,814
  • 12
  • 105
  • 142
1

use this my dear:

NSString *a = [name pathExtension];
saeid ezzati
  • 239
  • 1
  • 3
  • 16