My program compiles successfully, but when I press the button, it crashes. Here's the viewController.swift:
import UIKit
class ViewController: UIViewController, UIActionSheetDelegate{
@IBOutlet var button:UIButton
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonPressed(AnyObject) {
let choice = UIActionSheet(title: "Select source", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles:"camera", "libary")
choice.showInView(self.view)
}
}
The error appears on this line:
let choice = UIActionSheet(title: "Select source", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles:"camera", "library")
And here's error text:
EXC_BAD_ACCESS (code=2, address=0x0)
I tried to switch let to var, ran it on different simulators, but the result is same.