I'm new to Swift been reading but have no clue what this means. On the line of code below, I have "Expected expression in list of expressions" after parameters[String]. AS well at the same point it is looking for "Expected ',' separator. I believe these are related.
AppDelegate.submitLacunaRequest(module: "empire", method: "login", parameters[String]:["myuserid", "mypassword", "mykey"]) {
            responseObject, error in
            // some network error or programming error
            if error != nil {
                println("error = \(error)")
                println("responseObject = \(responseObject)")
                return
            }
            // network request ok, now see if login was successful
            if let responseDictionary = responseObject as? NSDictionary {
                if let errorDictionary = responseDictionary["error"] as? NSDictionary {
                    println("error logging in (bad userid/password?): \(errorDictionary)")
                } else if let resultDictionary = responseDictionary["result"] as? NSDictionary {
                    println("successfully logged in, refer to resultDictionary for details: \(resultDictionary)")
                } else {
                    println("we should never get here")
                    println("responseObject = \(responseObject)")
                }
            }
        }
Here is the related code from AppDelegate
public func submitLacunaRequest (#module: String, method: String, parameters: AnyObject, completion: (responseObject: AnyObject!, error: NSError!) -> (Void)) -> NSURLSessionTask? {
    let session = NSURLSession.sharedSession()
    let url = NSURL(string: "https://us1.lacunaexpanse.com")?.URLByAppendingPathComponent(module)
    let request = NSMutableURLRequest(URL: url!)
    request.HTTPMethod = "POST"
    request.setValue("application/json-rpc", forHTTPHeaderField: "Content-Type")
    let requestDictionary = [
        "jsonrpc" : "2.0",
        "id"      : 1,
        "method"  : "login",
        "params"  : ["myuserid", "mypassword", "mykey"]
    ]
    var error: NSError?
    let requestBody = NSJSONSerialization.dataWithJSONObject(requestDictionary, options: nil, error: &error)
    if requestBody == nil {
        completion(responseObject: nil, error: error)
        return nil
    }
    request.HTTPBody = requestBody
    let task = session.dataTaskWithRequest(request) {
        data, response, error in
        // handle fundamental network errors (e.g. no connectivity)
        if error != nil {
            completion(responseObject: data, error: error)
            return
        }
        // parse the JSON response
        var parseError: NSError?
        let responseObject = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &parseError) as? NSDictionary
        if responseObject == nil {
            // because it's not JSON, let's convert it to a string when we report completion (likely HTML or text)
            let responseString = NSString(data: data, encoding: NSUTF8StringEncoding) as String
            completion(responseObject: responseString, error: parseError)
            return
        }
        completion(responseObject: responseObject, error: nil)
    }
    task.resume()
    return task
}
                You are using external parameter name for a parameter when calling the function, but the external parameter is not defined in your function declaration. Simply use it this way.
submitLacunaRequest(module: "empire", "login", ["myuserid", "mypassword", "mykey"]) { 
You're calling the function incorrectly. You don't need the [String] in the parameters param...
AppDelegate.submitLacunaRequest(module: "empire", method: "login", parameters: ["myuserid", "mypassword", "mykey"]) {
    ...
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With