Reputation: 902
Good day
How do you get a filePath without fileName from a fullpath. Lets say I have a path:
NSString *myPath = @"/Users/myName/Library/Developer/CoreSimulator/Devices/.../Library/Caches/Getting Started.pdf";
and I want to just have
NSString *newPath = @"/Users/myName/Library/Developer/CoreSimulator/Devices/.../Library/Caches";
I didnt want to substring it, I hope there is a better solution.
Thank you in advance.
Upvotes: 2
Views: 1775
Reputation: 321
try this code
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSLog(@" DocumentPath %@",documentPath);
Upvotes: 1
Reputation: 7552
Check the class reference for NSString
.
newPath = [path stringByDeletingLastPathComponent];
Upvotes: 8