1

I'd like to call a function, which has parameters, from another function. This is the function which should be called: func saveDate(notiz: Notizen){}. I tried this: saveDate(notiz: Notizen)but I'm getting an error. Notizen is a class.

2 Answers 2

4

Compiler is right you should pass instance of the class not class itself:

let noti = Notizen() saveDate(notiz: noti) 

But if saveDate function is fiction declared as you shown inside the class you should drop the notiz word:

let noti = Notizen() saveDate(noti) 
Sign up to request clarification or add additional context in comments.

Comments

1

You have to make this call with an instance of Notizen, e.g.

let notizen = Notizen() // Depends on how you create an instance of Notizen saveDate(notizen) 

Note, that the first parameter name is not used, unless you specify it, e.g.

func saveDate(#notiz: Notizen) { } 

Would require you to write

saveDate(notiz: notizen) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.