5

Is there a framework or a library that I could use to split a file path into its components in iPhone SDK? I know I could code it myself, but I don't want to reinvent the wheel.

luvieere
  • 37,065
  • 18
  • 127
  • 179

4 Answers4

14

-[NSString pathComponents] is made exactly for this.

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256
0

I'm not completely sure, but NSFileManager's -subpathsAtPath method sounds like what you want to do. It splits up the components of a path into an NSArray.

EDIT: Actually, I might have misunderstood the documentation. Sorry if that's the case.

Jorge Israel Peña
  • 36,800
  • 16
  • 93
  • 123
0

You can probably just split at the character /; the relevant documentation says that "NSString represents paths generically with ‘/’ as the path separator and ‘.’ as the extension separator." So a simple

NSArray *components = [pathString componentsSeparatedByString:@"/"];

should suffice.

Tim
  • 59,527
  • 19
  • 156
  • 165
0

pathForResource? without using extension (Iphone)

One of the answers to this question provides the necessary code. Just the question is badly formulated.

Community
  • 1
  • 1
P i
  • 29,020
  • 36
  • 159
  • 267