You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using an API to pull JSON url objects back to my app and then mapping these object urls onto my cell with hanekeswift to simply set the image onto the cell. But I'm getting memory warning issues that may be related to hanekeswift or how hanekeswift is managing cache....
The following is a simple pseudo code of my code...
API call -> returns Objects in App -> append objects back into array of view controller -> reloadData -> Load cells with proper images and URL... -> If next pagination, repeat...
I remember reading how haneke is automagically managing my cache of these images... But I'd like to know if this would be a smart way of
// MyCollectionViewCell.swift
varmyObject:Object{
didSet{configureCell()}}func configureCell()self.topCoverImage.hnk_setImageFromURL(myObject.top_cover.url, placeholder:UIImage(), format:nil, failure:nil){(image)->()in
// Set image after success
self.topCoverImage.image = image
// Stop animation when fully loaded
self.activityIndicator.isHidden = true
self.activityIndicator.stopAnimating()}}
// MyCollectionViewController.swift
varmyArrayOfObjects:[Objects]=[] /// Is this Array getting too big after X amount of pagination
varmyPaginationfunc viewDidLoad{
super.viewDidLoad()loadMyFeed()}func loadMyFeed(page:Int, limit:Int){
api.getFeed(page:page, limit:limit){(myObjects, pagination)inself.myArrayOfObjects.append(myObjects)self.myPagination = pagination
self.collectionView.reloadData()}}func collectionView ...cellForItemAtIndexPath{
// deque cell
letcell=...
// set object for cell
cell.myObject =myArrayOfObjects[indexPath.row]
// detect if it is at the end of scroll
self.loadMyFeed(page:nextPage, limit:someLimit)}
I see that when my memory reaches above using 1GB ... the app crashes on my iPad but not my simulator because my PC has more memory to spare than does my iPad....
However, I'm looking for a solution to see if HanekeSwift can help me find a better way of managing my objects and then load them into the necessary cells with the proper images and url. I'm not too sure if this would be the most efficient way to handle image caching and my arrays together like this... Would love the insight on this.
Thanks!
The text was updated successfully, but these errors were encountered:
Are you using the dequeueing mechanism of UICollectionView? And are you removing objects from myArrayOfObjects when they've moved off-screen? You could also profile your app with Instruments to see where the memory's gone. Lastly, I'd look into Realm for managing large amounts of data. Only keep in memory what's directly on screen. Haneke is generally used for caching data that's either requested from an indirect source, like a web image, or something that's resource-intensive or processed. It looks like you need to off-hand data to disk, not to memory.
I'm using an API to pull JSON url objects back to my app and then mapping these object urls onto my cell with hanekeswift to simply set the image onto the cell. But I'm getting memory warning issues that may be related to hanekeswift or how hanekeswift is managing cache....
The following is a simple pseudo code of my code...
API call -> returns Objects in App -> append objects back into array of view controller -> reloadData -> Load cells with proper images and URL... -> If next pagination, repeat...
I remember reading how haneke is automagically managing my cache of these images... But I'd like to know if this would be a smart way of
I see that when my memory reaches above using 1GB ... the app crashes on my iPad but not my simulator because my PC has more memory to spare than does my iPad....
However, I'm looking for a solution to see if HanekeSwift can help me find a better way of managing my objects and then load them into the necessary cells with the proper images and url. I'm not too sure if this would be the most efficient way to handle image caching and my arrays together like this... Would love the insight on this.
Thanks!
The text was updated successfully, but these errors were encountered: