I am a beginner ios developer and i want to create a photo album app. I find some codes from internet and try to learn from there. In the app, when i click an album, it takes so much time for the album's collectionview of images to load. To fetch the images, my code is in ViewWillAppear. Can you help me optimize this code for better performance. If there is more than 10-15 images, this takes so long to load. Thanks in advance and sorry if my English is bad.
-(void)viewWillAppear:(BOOL)animated
{
// Call to the super classes implementation of viewWillAppear
[super viewWillAppear:YES];
/* The Photos are stored in Core Data as an NSSet. */
NSSet *unorderedPhotos = self.album.photos;
/* To organize them we use a NSSort descriptor to arrange the photos by date. */
NSSortDescriptor *dateDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES];
NSArray *sortedPhotos = [unorderedPhotos sortedArrayUsingDescriptors:@[dateDescriptor]];
self.photos = [sortedPhotos mutableCopy];
/* Now that the photos are arranged we reload our CollectionView. */
[self.collectionView reloadData];
}
Aucun commentaire:
Enregistrer un commentaire