Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of undeclared type 'Object'

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 {

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

like image 492
Alex Avatar asked Jul 17 '15 13:07

Alex


2 Answers

if you are using Realm then import

import RealmSwift

Complete syntax of class.

import UIKit
import RealmSwift

class User: Object {

}

If you face any difficulty to implement this code. Watch below video Link: https://youtu.be/5Z8tBKwk6-c

like image 53
Khawar Islam Avatar answered Sep 26 '22 01:09

Khawar Islam


Just remove : Object. Pure Swift classes don't need to inherit from a superclass

like image 42
vadian Avatar answered Sep 26 '22 01:09

vadian