D. Finna D. Finna - 1 year ago 120
iOS Question

Extra argument in call swift

I am trying to append two values to my variable

I get the error:
Extra argument 'code' in call
which does not make any sence to me because
is taking two values: Country and Code??

What have I done wrong?

Here is my code:

func startObersvingDB() {
FIRDatabase.database().reference().child("UserInformation").observeEventType(.ChildAdded, withBlock: { snapshot in

if let title = snapshot.value!["usersUID"] as? String {

if let name = snapshot.value!["userName"] as! String? {


for i in 0...self.tableData.count {
var countryAndCode: [(country:String, code: String)]
countryAndCode.append(self.tableData[i], code: self.tableDataNames[i])


} else {
print("Noget virker ikke i startObservingDB")



If it is relevant; I am trying to create a search bar that is showing the name of the user, while showing their picture also (which is why I need the id in tableData).

Answer Source

You simply need to encapsulate the arguments you are passing in, in brackets.

Change this: countryAndCode.append(self.tableData[i], code: self.tableDataNames[i])

to: countryAndCode.append((self.tableData[i], code: self.tableDataNames[i]))

The reason you need to this is because you are declaring your array with [(country:String, code: String)] with the brackets encapsulating the arguments inside the array, so you need to do the same when appending data to it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download