Error in UICollectionView reloadData


#1

What I do:
rootVC —> modalView1 —> modalView2 —> modalView3 —> dismiss modalView3 to rootVC then reload collectionView

dismissing to rootVC is working but having errors occur during collectionView.reloadData()

33897333_2240617469500807_8269539764114292736_n

Thanks in advance!

Project Repo: https://github.com/Creign/NilCollectionView


#2

hindi nman nil yung collection view?


#3

usable ung collection view and working tlga xa…


#4

After ng dismiss yung collectionview hindi nil?


#5

as lper display, hindi xa nil and working p xa kung hindi ako magrereload…


#6

how about yung actual [data] perhaps nil? Break point ka before reload then open mo yung variables view para makita mo yung mga objects


#7

i just tried breakpoints… nil nga xa, pero panu n gagawin dun? :frowning:


#8

check mo yung collectionview is created and how it is destroyed/deallocated


#9

aw!! panu un?! :frowning:


#10

PM me sa slack. We will share the solution later


#11

pm sent… :frowning:


#12

paanu ka magdismiss? and saang part ng code mu tinatawag ung displaySlots() ? :slight_smile:


#13

just added a project repo… thanks! :frowning:


#14

The last VC is referencing a new instance of the root therefore the outlets are not properly set. In this case I suggest to use an unwind segue


#15

Uu tama si @nmariano

hindi ku mapagana ung project hehe

Siguro simplest way is add mu ito

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
...
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "firstSegue" {
            if let secondModal = segue.destinationViewController as? SecondModal {
                secondModal.delegate = self
            }
        }
    }
extension RootViewController: SecondModalDelegate {
    func goToRoot(_ viewController: SecondModal) {
            self.collectionView.reloadData()
    }
}