I'm trying to build a function in my app through which users can add custom specifications to their products. the specifications should be added in an NSMutableArray, but when I want to add an object to it, I get an EXC_BAD_ACCESS error. here's my code:
var specs = NSMutableArray()
func addSpec () {
var alert = UIAlertController(title: "Nieuwe Specificatie", message: "Vul hier een naam voor de nieuwe specificatie in:", preferredStyle: UIAlertControllerStyle.Alert)
alert.addTextFieldWithConfigurationHandler(configurationTextField)
alert.addAction(UIAlertAction(title: "Opslaan", style:UIAlertActionStyle.Default, handler: {(UIAlertAction) in
self.specs.addObject(self.newSpecificationTitle.text)
}))
alert.addAction(UIAlertAction(title: "Annuleren", style:UIAlertActionStyle.Default, handler: {(UIAlertAction) in
println("annuleren")
}))
self.presentViewController(alert, animated: true, completion:nil)
}
Can anybody see what I'm doing wrong?
var specsproperty or local variable?self.newSpecificationTitlenot nil?NSMutableArray(), use anArray