0
votes

I finished building a task iOS app using Swift. The whole app was completed and finished with no errors and was functioning correctly. I was using Xcode 6 but I upgraded to the latest Xcode Beta not long ago which is Xcode 7 Beta. In one of my swift files, since some of the logic has been altered from switching xcode 6 to xcode 7 beta, there is only one error that was once not an error from xcode 6. In my of my lines the error was; "Cannot invoke 'taskCreated' with an argument list of type '([String : String?])'" How do I get around this error?

The line of code is below:

delegate!.taskCreated(["name": nameTask, "description": descriptionTask])

If anyone wants to see my "taskCreated" function, I'll post it below here as well.

func taskCreated(task: Dictionary<String, String>) {
    print("in task created delegate of ViewController")
    print(task)

    dataSource[0].append(task)


    tableView.reloadData()
}
2
try like this delegate!.taskCreated(["name": nameTask, "description": descriptionTask!]) - Leo Dabus

2 Answers

0
votes

One of nameTask or descriptionTask is of type String?. You can unwrap them with an exclamation mark:

delegate!.taskCreated(["name": nameTask!, "description": descriptionTask!])
0
votes

The variable nameTask or descriptionTask is not a String but an Optional(String) (represented as String?) which is why it says you cannot call taskCreated with [String: String?]. You can only send [String: String].

If you're sure nameTask and descriptionTask are never nil, just replace its call with: delegate!.taskCreated(["name": nameTask!, "description": descriptionTask!])