I am new to iPhone,
I made an app in which, i am downloading a book and storing it in a folder called book1Folder
which is inside Document directory
.
now i wants name of all books in my array, there are 2 books inside a book1Folder
but when i write this code it shows me array count is 3.
Here is my code snippet,
-(void)viewWillAppear:(BOOL)animated{
NSString *files;
NSString *Dir=[self applicationDocumentsDirectory];
Dir=[Dir stringByAppendingPathComponent:@"book1Folder"];
NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager] enumeratorAtPath:Dir];
Downloadedepubs = [[NSMutableArray alloc]init];
while(files = [direnum nextObject])
{
if([[files pathExtension] isEqualToString:@"epub"])
NSLog(@"files=%@",files);
[Downloadedepubs addObject:files];
}
}
My log shows only name of 2 book, but when i loop through array it contains 3 objects.
[Downloadedepubs ObjectAtIndex:0]=.DS_Store;
[Downloadedepubs ObjectAtIndex:1]=abcd;
[Downloadedepubs ObjectAtIndex:2]=pqrs;
What is that .DS_Store
why it is coming ?
Any help will be appreciated.
Get your if block in curly brackets. It affects only first line after if.
Like below;
if([[files pathExtension] isEqualToString:@"epub"]) {
NSLog(@"files=%@",files);
[Downloadedepubs addObject:files];
}