user2498079
user2498079

Reputation: 3002

NSURLConnection crashing the app

I am downloading Json data from server using NSURLConnection class. I parse the data in background thread, however in connection() delegate method the app is crashing. Below is the screenshot. The code is also available in the image below. Why is this happening?

Regards

enter image description here

UPDATE:

With breakpoints removed:

enter image description here

Upvotes: 0

Views: 320

Answers (1)

sergio
sergio

Reputation: 69027

It seems that you are trying to use UIAlertView and that is causing a crash. Now, from your code is not clear how you are doing that. In any case UIAlertView is deprecated under iOS 8 and this might explain the issue when using Swift (although using deprecated methods or classes does not usually causes a crash in Obj-C).

You could try with a UIAlertController and set its preferredStyle to UIAlertControllerStyleAlert:

var alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)

Upvotes: 1

Related Questions