There is nothing wrong with the code. The problem is the values โโthat are loaded in
var currentUserFirstName: String! var currentUserLastName: String!
As a test, I created a sample project with the following code, which is a duplicate of your published code, but with normal lines loaded in var:
var myRootRef = Firebase(url:"https://myproject.firebaseIO.com/") var currentUserFirstName = "Test" var currentUserLastName = "User" var currentUserObjectID = "object ID" var attendeesArray = ["objectID": currentUserObjectID, "name": currentUserFirstName + " " + currentUserLastName] var eventRefChild = myRootRef.childByAutoId() eventRefChild.setValue([ "eventName": "eventName", "attendees": attendeesArray ])
The project is compiled and working correctly, and the expected data is written to Firebase. Note that eventName.text has also been replaced with a string, but this does not affect the response.
The study should go to what is loaded in var, and the answer is that one of these var variables, currentUserFirstName or currentUserLastName is loaded by an OBJECT (class), not a string.
As a side note, why var is declared as implicitly expanded options (!!)
edit: add additional information for working with options
if let actualString = currentUserFirstName { println(actualString)
To exclude code from errors, if the option does not contain a value, add the code above directly above the code concatenation line. What happens here, we assign a string in currentUserFirstName (optional var) to the actual string (standard, optional var).
If the expression is true, we can continue to evaluate currentUserFirstName.
If this is false, then currentUserFirstName does not contain a string, so handle the error elegantly.