表达式列表中预期的“,”分隔符和预期的“)”
Expected ',' seperator and expected ')' in expression list
我从以下脚本中收到两个错误:
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
data, response, error in
if error != nil {
print("error=\(error)")
return
}
do {
if let parseJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
print(parseJSON)
let resultValue:String = parseJSON["status"] as! String
print("Result: \(resultValue)")
print(userEmail)
print(userPassword)
var isUserRegistered:Bool = false;
if(resultValue=="Success") { isUserRegistered = true; }
var messageToDisplay:String = parseJSON["message"] as! String!;
if(!isUserRegistered)
{
messageToDisplay = parseJSON["message"] as! String!;
}
dispatch_async(dispatch_get_main_queue(), {
//Display alert message with confirmation
let myAlert = UIAlertController(title: "Alert", message:messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title:"Alert", style:UIAlertActionStyle.Default){
action in self.dismissViewControllerAnimated(true, completion:nil);
}
myAlert.addAction(okAction)
self.presentViewController(myAlert, animated:true, completion:nil);
)};
}
}
catch let error as NSError {
print(error.localizedDescription)
}
}
task.resume()
}
}
第一个错误是:Expected ',' seperator
这一行:
)};
它对 insert ","
说,但它是一个持续的错误,并且不会结束。
在下面的下一行,它只是一个括号 }
,我得到错误:Expected ')' in the expression list
}) 不是 )}
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
data, response, error in
if error != nil {
print("error=\(error)")
return
}
do {
if let parseJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
print(parseJSON)
let resultValue:String = parseJSON["status"] as! String
print("Result: \(resultValue)")
print(userEmail)
print(userPassword)
var isUserRegistered:Bool = false;
if(resultValue=="Success") { isUserRegistered = true; }
var messageToDisplay:String = parseJSON["message"] as! String!;
if(!isUserRegistered)
{
messageToDisplay = parseJSON["message"] as! String!;
}
dispatch_async(dispatch_get_main_queue(), {
//Display alert message with confirmation
let myAlert = UIAlertController(title: "Alert", message:messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title:"Alert", style:UIAlertActionStyle.Default){
action in self.dismissViewControllerAnimated(true, completion:nil);
}
myAlert.addAction(okAction)
self.presentViewController(myAlert, animated:true, completion:nil);
});
}
}
catch let error as NSError {
print(error.localizedDescription)
}
}
task.resume()
}
}
我从以下脚本中收到两个错误:
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
data, response, error in
if error != nil {
print("error=\(error)")
return
}
do {
if let parseJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
print(parseJSON)
let resultValue:String = parseJSON["status"] as! String
print("Result: \(resultValue)")
print(userEmail)
print(userPassword)
var isUserRegistered:Bool = false;
if(resultValue=="Success") { isUserRegistered = true; }
var messageToDisplay:String = parseJSON["message"] as! String!;
if(!isUserRegistered)
{
messageToDisplay = parseJSON["message"] as! String!;
}
dispatch_async(dispatch_get_main_queue(), {
//Display alert message with confirmation
let myAlert = UIAlertController(title: "Alert", message:messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title:"Alert", style:UIAlertActionStyle.Default){
action in self.dismissViewControllerAnimated(true, completion:nil);
}
myAlert.addAction(okAction)
self.presentViewController(myAlert, animated:true, completion:nil);
)};
}
}
catch let error as NSError {
print(error.localizedDescription)
}
}
task.resume()
}
}
第一个错误是:Expected ',' seperator
这一行:
)};
它对 insert ","
说,但它是一个持续的错误,并且不会结束。
在下面的下一行,它只是一个括号 }
,我得到错误:Expected ')' in the expression list
}) 不是 )}
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
data, response, error in
if error != nil {
print("error=\(error)")
return
}
do {
if let parseJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
print(parseJSON)
let resultValue:String = parseJSON["status"] as! String
print("Result: \(resultValue)")
print(userEmail)
print(userPassword)
var isUserRegistered:Bool = false;
if(resultValue=="Success") { isUserRegistered = true; }
var messageToDisplay:String = parseJSON["message"] as! String!;
if(!isUserRegistered)
{
messageToDisplay = parseJSON["message"] as! String!;
}
dispatch_async(dispatch_get_main_queue(), {
//Display alert message with confirmation
let myAlert = UIAlertController(title: "Alert", message:messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title:"Alert", style:UIAlertActionStyle.Default){
action in self.dismissViewControllerAnimated(true, completion:nil);
}
myAlert.addAction(okAction)
self.presentViewController(myAlert, animated:true, completion:nil);
});
}
}
catch let error as NSError {
print(error.localizedDescription)
}
}
task.resume()
}
}