I've been working on a web service for my application in Swift, but I just tested it and it gave me a weird breakpoint at a line in swift_dynamicCastObjectObjCClassUnconditional
.
It occurs at
0x104bbb7a2: nopw %cs:(%rax,%rax) and says "Thread 1: EXC_BREAKPOINT (code=EXC_l386_BPT, subcode=0x0)"
It occurs when I after I press my button.
import UIKit
class ViewController: UIViewController, NSURLConnectionDelegate {
lazy var data = NSMutableData()
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBAction func attemptLogin(sender: UIButton) {
if(usernameTextField.text == "" || passwordTextField.text == "") {
var alert = UIAlertController(title: "Error", message: "Invalid Credentials", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
} else {
attemptConnection(usernameTextField.text, password: passwordTextField.text)
}
}
override func viewDidLoad() {
super.viewDidLoad()
var tapBackground: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard:")
tapBackground.numberOfTapsRequired = 1;
self.view.addGestureRecognizer(tapBackground)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func dismissKeyboard(sender: AnyObject) {
self.view.endEditing(true)
}
func attemptConnection(username: String, password: String){
let urlPath: String = "http://notmywebsite.com/getusers.php?username=" + username + "&password=" + password
var url: NSURL = NSURL(string: urlPath)!
var request: NSURLRequest = NSURLRequest(URL: url)
var connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: false)!
connection.start()
activityIndicator.startAnimating()
}
func connection(connection: NSURLConnection!, didReceiveData data: NSData!){
self.data.appendData(data)
}
func connectionDidFinishLoading(connection: NSURLConnection!) {
var err: NSError
var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary
println(jsonResult)
activityIndicator.stopAnimating()
}
}