ios - 将 Swift 添加到 Objective-C 项目编译错误

标签 ios objective-c swift

Hi Im getting the following error on my class definition

Im getting the following error on my class definition

expected '{' in class

My define Module = Yes bridge.h is setup

embedded content contains swift = Yes

Code is as follows

    class HeaderFooterView : UIView {



    override init(frame: CGRect){
        super.init(frame: frame)
        self.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
        self.autoresizesSubviews = true
        self.backgroundColor = UIColor.clearColor()

    }


    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
        self.autoresizesSubviews = true
        self.backgroundColor = UIColor.clearColor()
    }

}

有什么想法吗?

最佳答案

在类前添加@objc

@objc class HeaderFooterView : UIView {

关于ios - 将 Swift 添加到 Objective-C 项目编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33224459/

相关文章:

ios - 类型 'MyWeights' 不符合协议(protocol) 'NSCopying'

objective-c - 保存使用 NSCoder 编码的数据

objective-c - 未指定目标且未找到 makefile

ios - 崩溃报告,找到应用程序崩溃的帧

IOS Swift CNContactViewController 导航栏不显示 UINavigation Controller

ios - UISearchBar 范围空白

ios - 'EXC_BAD_ACCESS code=2' 尝试将对象从 VC 设置为另一个时发生错误

objective-c - 使用 OCMock 模拟 block 期望

ios - 如何使用自定义类在 UITextField 的左侧添加图像

ios - EKCalendar 中的 "full calendar sync"到底是什么?