I have an application which has a collection view full of videos and images. When you tap on one of them you segue to a full screen to view the media. When I tap a image It works as needed. But when I run my application and tap one of those videos I get the error shown bellow:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x8000000000000010)
I get this here:
class AppDelegate: UIResponder, UIApplicationDelegate {
Is this possibly due to memory problems?
What is happening and how do i fix this?
I have looked here but was unable to solve it.
I have found that the fail actually occurs when the bellow function is called.
func getAndShowMedia(post: Post) {
if post.media[numberMedia].image != nil {//here is still works, I am assuming this line is the line which actualy fails
print("imageooooo")//When setting break point here it will crash
mediaView.image = nil
mediaView.image = (post.media[numberMedia].image)!
} else {
mediaView.layer.removeFromSuperlayer()
let videoURL = post.media[numberMedia].videoURL
let player = AVPlayer(url: videoURL! as URL)
let playerLayer = AVPlayerLayer(player: player)
print("videooooooo")
playerLayer.frame = mediaView.bounds
mediaView.layer.addSublayer(playerLayer)
player.play()
}
}
Here:
func loadOtherData() {
getAndShowMedia(post: selectedPost!)
}