I have a view that has custom cells like shown, when I hit a button in the cell, the entire app freezes and I have to force close it and restart it. Nothing is shown in the console when the app freezes and I have no idea how to debug this. I've also tried using non custom buttons.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//delete button
@IBAction func deleteButton(sender: AnyObject) {
if phonee == "0"{
let URL = "BLURRED FOR PRIVACY"
var url : NSString = URL
var urlStr : NSString = url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
var searchURL : NSURL = NSURL(string: urlStr as String)!
print (searchURL)
let task = NSURLSession.sharedSession().dataTaskWithURL(searchURL, completionHandler: { (data, response, error) -> Void in
var urlContent = NSString(data: data!, encoding: NSASCIIStringEncoding) as NSString!
print(urlContent)
if urlContent.localizedStandardContainsString("Removed event with ID") {
dispatch_sync(dispatch_get_main_queue()) {
var settings = Modal.Settings()
settings.bodyColor = .whiteColor()
Modal(title: "Success", body: "Task deleted, refresh the page.", status: .Success, settings: settings).show()
}
}else{
dispatch_sync(dispatch_get_main_queue()) {
var settings = Modal.Settings()
settings.bodyColor = .whiteColor()
Modal(title: "Error", body: "Are you connected to the internet?", status: .Error, settings: settings).show()
}
}
})
task.resume()
}else{
dispatch_sync(dispatch_get_main_queue()) {
var settings = Modal.Settings()
settings.bodyColor = .whiteColor()
Modal(title: "Error", body: "You can't delete an accepted task", status: .Error, settings: settings).show()
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //pay button
@IBAction func payButton(sender: AnyObject) {
if phonee == "0"{
dispatch_sync(dispatch_get_main_queue()) {
var settings = Modal.Settings()
settings.bodyColor = .whiteColor()
Modal(title: "Error", body: "Please wait for the task to be accepted", status: .Error, settings: settings).show()
}
}else{
url = url + userID + "&event_id=" + eventID
let myURL = NSURL(string: url)!
print (myURL)
let task = NSURLSession.sharedSession().dataTaskWithURL(myURL, completionHandler: { (data, response, error) -> Void in
var urlContent = NSString(data: data!, encoding: NSASCIIStringEncoding) as NSString!
print(urlContent)
})
task.resume()
progressBar.progress = 1.0
complete1.textColor = UIColor(red: 43/255.0, green: 192/255.0, blue: 228/255.0, alpha: 1.0)
accepted1.textColor = UIColor.blackColor()
reportButton.userInteractionEnabled = false
deleteButton.userInteractionEnabled = false
contactButton.userInteractionEnabled = false
payButton.userInteractionEnabled = false
priceLabel.textColor = UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1.0)
self.deleteButton.backgroundColor = UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1.0)
self.contactButton.backgroundColor = UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1.0)
self.payButton.backgroundColor = UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1.0)
priceLabel.textColor = UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1.0)
reportButton.setImage(UIImage(named: "nation2.png"), forState: UIControlState.Normal)
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //contact button
@IBAction func contactButton(sender: AnyObject) {
if phonee == "0"{
dispatch_sync(dispatch_get_main_queue()) {
var settings = Modal.Settings()
settings.bodyColor = .whiteColor()
Modal(title: "Error", body: "Please wait for the task to be accepted", status: .Error, settings: settings).show()
}
}else{
if let url = NSURL(string: "tel://\(phonee)") {
UIApplication.sharedApplication().openURL(url)
}
}
}