I'm quite new to the iOS platform, but am already an experimented Android dev.
I'm experiencing a weird issue in Swift, we cannot reproduce in Objectice-C. We are designing our interfaces by hand, without using the Interface Builder, to have more flexibility.
We are getting a EXC_BAD_ACCESS on the mentioned line in our custom UIViewController. While the question seems to have been asked many times on StackOverflow, I either haven't found a solution written in Swift or a solution which was working properly and a really similar problem.
override func viewDidLoad() {
super.viewDidLoad()
var logo:UIImage = UIImage(named: "sgLogo")! --> EXC_BAD_ACCESS
var sgLogo:UIImageView = UIImageView(image: logo)
// other UI elements, + constraints
[...]
}
The only element I get is a stack trace, the debugger view in the bar below Xcode is empty. According to that stack trace, the UIImage seems to be instantiated: presence of a memory address.
The sgLogo image is a png image located in the project folder structure not in Images.xcassets. I tried to specify it in the images assets, but I'm still experimenting the same issue. Specifying the extension or not does not help either.
I can provide more code snippets if you want.
I succeeded to solve the issue. I was overriding the loadView
method of my UIViewController
, but not calling the parent method. Problem solved.