int intSort(id string2, id string1, void *locale)
{
static NSStringCompareOptions comparisonOptions =
NSCaseInsensitiveSearch | NSNumericSearch |
NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSRange string1Range = NSMakeRange(0, [string1 length]);
return [string1 compare:string2
options:comparisonOptions
range:string1Range
locale:(NSLocale *)locale];
}
-(void) updateList{
{
NSArray* filename = [self getFilenamelistOfType:@"png"
fromDirPath:[Utilities documentsPath]];
NSArray *sortedArray;
sortedArray = [filename sortedArrayUsingFunction:intSort context:NULL];
self.listData = sortedArray;
[self.tableView reloadData];
}
}
-(NSArray *) getFilenamelistOfType:(NSString *)type fromDirPath:(NSString *)dirPath
{
NSArray *fileList = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:dirPath error:nil]
pathsMatchingExtensions:[NSArray arrayWithObject:type]];
return fileList;
}