How do I get a relative path of the file in my project? (IPhone)


Suppose, I have added one folder name "Images" in my project.How can I get the path to that folder? My main intention is to get the number of pictures in "Images" folder.

You should work a bit more on your question: it assumes a lot and requires the reader to guess.

I have added one folder name "Images" in my project

So I guess this means you added it as a folder reference

and I want to get it's path

And I guess that you want to do that at run time from your application, not at build-time from Xcode.

If so, you could do something like:

NSURL *containingURL = [[NSBundle mainBundle] resourceURL];
NSURL *imageURL = [containingURL URLByAppendingPathComponent:@"Images" isDirectory:YES];
NSFileManager *localFileManager = [[NSFileManager alloc] init];
NSArray *content = [localFileManager contentsOfDirectoryAtURL:imageURL includingPropertiesForKeys:nil options:NSDirectoryEnumerationSkipsSubdirectoryDescendants error:NULL];
[localFileManager release];
NSUInteger imageCount = [content count];

This code does not assume that all images are of the same kind.