Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Hamza Hasan
Courses Plus Student 30 PointsI Have An Issue On The Memory warning when i try to get all images from photo library
hello all i hope all is well
I have an issue on the leak memory warning when I try to get all images from photo library using photos framework. when I try to get the assets on size PHImageManagerMaximumSize I Have display message memory warning and then app crash and when I try to get the assets on size (125 * 125) it is work good but when I try to save the image to document directory it save it but the image in document directory not clear(no have quality) when I try to get the image for display it for the user can anyone give me the way for better than my code to get images from photo library without memory warning
I surfed the internet for a long time but haven't found the solution yet.
Thanks advance
The following is my code :
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = myCollectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! SelectImagesCollectionViewCell
if photoAsset.count > 0 {
let asset = photoAsset[indexPath.row] as! PHAsset
PHImageManager.defaultManager().requestImageForAsset(asset, targetSize: PHImageManagerMaximumSize, contentMode: .AspectFit, options: nil, resultHandler: { (img:UIImage?, obj:[NSObject:AnyObject]?) in
// her i display images but the memory warning and app crash
cell.imageViewCell.image = img
})
}
return cell
}
please help because i ask every where and no one answer on this question and my app not created because this problem if anyone can help me
thanks advance