Oleg Oleg - 4 months ago 58
Swift Question

objective-c - Swift classes are not visible in Objective-C .h file

I'm trying to use Swift class in my Objective-C file.
I included

"moduleName-Swift.h"
file in my
SuperViewController.m
file, but when I try to declare a public method in
SuperViewController.h
with
Swift-class
as method parameter, I obviously get an error:
"Expected a type"


How can I use
swift-class
in a header file if I can only include
projectModule-Swift.h
in
.m
files??

Answer

Make sure to put @objc before the swift class name.

@objc myclassname { ... }

Also add

@class myclassname;

in your obj-c header file where you want to access the swift class