Skip to content
Argument passed to call that takes no arguments

Argument passed to call that takes no arguments

DodaTech 2 min read

The “Argument passed to call that takes no arguments” error means you are supplying parameters to a function or initializer that does not accept any. This is a compile-time error that stops your build.

What It Means

Every function and initializer in Swift has a defined signature listing its parameters. When you provide arguments to a function that expects zero parameters, the compiler flags the mismatch. This often happens due to subtle syntax issues: extra parentheses, calling a computed property as a method, or confusing type construction with a function call.

Why It Happens

  • Extra parentheses on a computed propertyview.backgroundColor() instead of view.backgroundColor.
  • Calling an initializer with no parameters incorrectlyMyClass() works but MyClass(param: value) fails if no init takes parameters.
  • Wrong function name — you intended to call configure(with: value) but typed configure() or vice versa.
  • Trailing closure syntax confusion — adding a closure argument to a function that does not accept one.
  • Calling a method that takes no arguments with empty parentheses incorrectly — writing someFunc() when the function is defined as func someFunc() (this actually works — the error usually means the argument labels do not match or you are passing an argument to a parameter-less function).

How to Fix It

1. Remove the parentheses for computed properties

// ❌ backgroundColor is a property, not a method
let bg = view.backgroundColor()

// ✅ Access as a property
let bg = view.backgroundColor

2. Check the function signature

// Given: func reset()
// ❌
reset(animated: true)

// ✅
reset()

3. Use the correct initializer

// Given: struct Point { init(x: Int, y: Int) }
// ❌
let p = Point()

// ✅
let p = Point(x: 10, y: 20)

4. Remove arguments from parameter-less functions

class ViewController {
    func setupUI() {
        // ...
    }
    
    func viewDidLoad() {
        // ❌
        setupUI(with: backgroundColor)
        
        // ✅
        setupUI()
    }
}

5. Verify trailing closure usage

// Given: func perform()
// ❌ Trailing closure when function takes no closure
perform() {
    print("done")
}

// ✅ Just call the function
perform()
How do I find the exact function signature in Xcode?
Option-click on the function name to see its declaration. Xcode Quick Help shows the full signature including parameter names and types.
Is there a difference between () and Void parameters?
No — func foo() and func foo() -> Void are equivalent. Both take zero arguments. The error usually comes from calling them with arguments, not from the declaration syntax.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro