使用未声明类型的“对象" [英] Use of undeclared type 'Object'
问题描述
这太奇怪了.通常,我可以理解未声明的类,但这声称没有声明Object类本身. NSObject可以工作,但是我的项目设置方式需要它是一个纯Swift对象.我的班级标题看起来像这样:
This is so weird. Normally I could understand a class not being declared, but this is claiming the Object class itself is not declared. NSObject works, but the way my project is setup I need it to be a pure Swift Object. My class header looks like this:
import UIKit
import Foundation
class Person: Object {
我知道基础并不是必须的,我只是添加了基础,因为我不确定这是否引起了我的问题.这个问题在实际项目和游乐场以及Xcode 6和带有Swift 2.0的最新Xcode 7 beta中都发生了
I know foundation isn't really necessary, I just added it because I wasn't sure if that was causing me issues. The issue is occurring in both actual projects and playgrounds as well as in Xcode 6 and the latest Xcode 7 beta with Swift 2.0
推荐答案
只需删除: Object
.纯Swift类不需要从超类继承
Just remove : Object
. Pure Swift classes don't need to inherit from a superclass
这篇关于使用未声明类型的“对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!