Can you create a property in the PHAssetCollection class that takes order into account? That way you can show them based on the property.
A very simple example: if a class contains a number from 1 - n, based on this number, do you know which class / photo will be displayed? (or sort them based on this property, and you can just loop it after sorting.)
@Edit A simple example:
In the PHAssetCollection class in the .h file, you declare a property.
@property (retain, nonatomic) NSInteger id;
In the PHAssetCollection class in the .m file, you can fill it with the initialization method. If you want to use it in a .m file, you need to synthesize it. You can refuse the course to fill out, as always and whenever you want, it depends on your needs. I can imagine that they get a standard identifier, and when a user drags a photo, he sets a new identifier on it.
You can sort your list based on the following: implement the comparison method and call the comparison function:
//Implement - (NSComparisonResult)compare:(PHAssetCollection *)otherPhoto{ return [self.id compare:otherPhoto.id]; } //Call method NSMutableArray *sortedArray; sortedArray = [sub sortedArrayUsingSelector:@selector(compare:)];
There are many ways to do this. Another tricky one is keeping track of the order in the background and not changing the identifier every time you change an order. When ApplicationWillTerminate or ApplicationDidEnterBackground is called, you change the identifier of the photos based on the order of the photos. This way, you only need to change the identifier once, and this will save you some performance.
Sliver2009
source share