I m making an array of images animate like a flicker book animation,i m storing these images inside a folder which intern resides inside Resource folder of my project in xcode.. these images will vary,that is why i have to determine the exact number of images inside the folder so how should i determine this? is there any API in cocoa to achieve this?
Try
int paths = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/your/path/here" error:NIL] count];
For more info, http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html
First, you need to access the bundle path of your application:
NSMutableString* bundlePath = [NSMutableString stringWithCapacity:4];
[bundlePath appendString:[[NSBundle mainBundle] bundlePath]];
Now append your folder name to the bundlePath
[bundlePath appendString:@"/MyFolder"];
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundlePath error:nil];
int numberOfFileInFolder = [directoryContent count];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With