This is on XCode 6.2.
If I run the app in release mode it will crash, but with optimizations off it does not crash. The code looks straightforward. I have programmed ObjC for over a decade, so not new to programming, etc.
I note that in 32 bit it runs fine in release mode (Fastest -O), but on 64 bit real iOS hardware it crashes.
Is this a compiler bug ? Or is it possible to have poor swift that crashes only for some compiler settings (which can happen in C!).
I include code, but I'm not sure that it will help.
class func attemptLogin(completionHandler: (result: JSON?, error: NSError?) -> ()) {
// It appears that these variables are not working in the completion block in 64 with optimization on.
let email = User.email
let password = User.password
// setup login.
let parameters: [String : AnyObject] = [
"action": "login",
"login": [
"email": email,
"password": password,
"type": User.type
]
]
// Fire off REST POST Async
request(.POST, baseUrl, parameters: parameters, encoding: .JSON)
.responseSwiftyJSON { (request, response, jsonDict, error) in
// in release mode on 64 bit, things are seriously bad here.
println("jsonDict login attempt: ")
print(jsonDict)
if let token = jsonDict["login"]["token"].string {
println("token found is: " + token)
User.token = token;
User.email = email;
User.password = password;
completionHandler(result: jsonDict, error: nil)
} else {
println("No Token")
User.token = "";
User.email = "";
User.password = "";
let errorNS = NSError(domain: "stethIoUser", code: 404, userInfo: nil)
completionHandler(result: jsonDict, error: errorNS)
}
}
}