我有数千个PHAssets
数组(arrayOfAsset),我知道如何按创建日期对该数组进行排序。
[[arrayOfAsset objectAtIndex:j1 ] sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]]];
但我不知道如何按资产大小对该数组进行排序。
答案 0 :(得分:0)
您好,您可以使用pixelWidth
和pixelHeight
根据尺寸进行粗略排序。假设只有照片。对于视频,您需要在排序中包含duration
。
NSSortDescriptor *sortByWidth = [NSSortDescriptor sortDescriptorWithKey:@"pixelWidth" ascending:YES];
NSSortDescriptor *sortByHeight = [NSSortDescriptor sortDescriptorWithKey:@"pixelHeight" ascending:YES];
[[arrayOfAsset objectAtIndex:j1] sortUsingDescriptors:@[sortByWidth,sortByHeight]];