Search code examples
iosobjective-cswiftundeclared-identifier

What is wrong that shows "Use of undeclared type" after adding an function?


I am writing a swift project mixing with others' project writing in Objective-C. I have already used a bridging header file. And it works.

I am now using some function from others' project. Before I add the functions, which have been declared in .h file. It works: enter image description here

However, when I add the function:

func SACalendar(calendar: SACalendar!, didSelectDate day: Int32, month: Int32, year: Int32) {

}

Errors occur:

Use of undeclared type 'SACalendar'!

enter image description here


Solution

  • The problem is that you define a method with the same name SACalendar as an existing class. This instance method "hides" the class definition within class Calendar.

    Renaming func SACalendar(...) should solve the problem.