Undo invocation

Hi, I am using Xcode 6.3. In the RaiseMan application I am trying to write the func insertObjet(…). At the following line, I have an error:

The error is:
‘AnyObject’ does not have a member named ''removeObjectFromEmployeesAtIndex"

How do I correct this error?


  1. That is not what the error message says. Do not type in error messages. Copy and paste them. Every detail is important.

  2. When you post code, post the whole function surrounded by code tags.

I was able to reproduce your error by writing:

    func insertObject(employee: Employee, inEmployeesAtIndex index: Int) {
        println("Inserting \(employee) at index \(index)")
        let undo: NSUndoManager = undoManager!

(See what code tags do?)

Which produces the error message:

(See what quote tags do?)

Notice the name of the function in the error message:

The error message says that there is no function by that name, which takes 0 arguments. In Swift, functions have names such as:

removeObjectFromEmployeesAtIndex() --> takes no arguments removeObjectFromEmployeesAtIndex(_:) --> takes one unnamed argument removeObjectFromEmployeesAtIndex(_:arg2:) --> takes one unnamed argument and one argument named arg2

All of those functions are different.

But you claim to have written:

undo.prepareWithInvocationTarget(self) .removeObjectFromEmployeesAtIndex(employees.count)

and that the error message says:

And those don’t match up. If that is actually your code, try manually saving the file, then rerunning.

I have the same problem. The code is:



Value of type ‘AnyObject’ has no member ‘removeObjectFromEmployeesAtIndex’

This seems to say that there is no such command.

I have the same problem with your post that I spelled out in my answer:

  1. It is NEVER okay to post code without code tags.

  2. It is NEVER okay to post a single line of code.