技术的乐趣在于分享,欢迎多多交流,多多沟通。
全部博文(877)
分类: iOS平台
2015-11-16 16:57:00
http://blog.sina.com.cn/s/blog_6317728d0102v4jl.html
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;
}