I got the error below when trying to apply dequeueReusableCell to the MenuCollectionViewCell for which I created the file and changed the cell in the storyboard to this class. I am following this tutorial from raywenderlich. I checked the code with an example and could not find the error. What are the common errors causing this error?
If I changed the casting to as UICollectionViewCell , then the error will disappear.
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as MenuCollectionViewCell cell.backgroundColor = UIColor.lightGrayColor() return cell }
Error:
libswiftCore.dylib`swift_dynamicCastClassUnconditional: 0x10bd39860: pushq %rbp 0x10bd39861: movq %rsp, %rbp 0x10bd39864: testq %rdi, %rdi 0x10bd39867: je 0x10bd3989e ; swift_dynamicCastClassUnconditional + 62 0x10bd39869: movabsq $-0x7fffffffffffffff, %rax 0x10bd39873: testq %rax, %rdi 0x10bd39876: jne 0x10bd3989e ; swift_dynamicCastClassUnconditional + 62 0x10bd39878: leaq 0xb52e9(%rip), %rax 0x10bd3987f: movq (%rax), %rax 0x10bd39882: andq (%rdi), %rax 0x10bd39885: nopw %cs:(%rax,%rax) 0x10bd39890: cmpq %rsi, %rax 0x10bd39893: je 0x10bd398ad ; swift_dynamicCastClassUnconditional + 77 0x10bd39895: movq 0x8(%rax), %rax 0x10bd39899: testq %rax, %rax 0x10bd3989c: jne 0x10bd39890 ; swift_dynamicCastClassUnconditional + 48 0x10bd3989e: leaq 0x36b7d(%rip), %rax ; "Swift dynamic cast failed" 0x10bd398a5: movq %rax, 0xb4c0c(%rip) ; gCRAnnotations + 8 0x10bd398ac: int3 0x10bd398ad: movq %rdi, %rax 0x10bd398b0: popq %rbp 0x10bd398b1: retq 0x10bd398b2: nopw %cs:(%rax,%rax)
Update: If you tried to check the cell type with the code below and got a false, although I set it to MenuCollectionViewCell in the storyboard.
print( cell is MenuCollectionViewCell ) => false

source share