tags:

views:

20

answers:

2

I want to simply display array data of my directory for which i tried this code..directory is in resources folder..code is below..may i know what is going wrong..data is not displaying after i press a button

@implementation filemanagerViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    filemag =[NSFileManager defaultManager];
}


-(IBAction)buttonpress:(id)sender
{
    filelist=[filemag directoryContentsAtPath:@"directory.plist"];
    count=[filelist count];

  //i used a 'for loop here' for i<count

   NSLog(@"%@",[filelist objectAtIndex:i]);
}
A: 

"directory.plist" is not a path

JustSid
i used direcly from resources...we cant do this way??
vidhya jain
A: 

NSFileManager takes absolute path, you are passing directory.plist then that directory must exist in root directory otherwise it will return null.

To get the resource folder path use NSBundle class, you can use may be following api to get path:
+ (NSBundle *)mainBundle
+ (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)bundlePath

PS:Documentaion says the API you are using is deprecated

Devara Gudda