Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode 8.2 swift 3 Core data -- use unresolved identifier

I have created a core data project in xcode 8.2, After that I created an entity say "TestEntity" in .xcdatamodeld

I am creating entity object by using following code as per given in some tutorials for swift3. enter link description here

    let appDele = (UIApplication.shared.delegate) as! AppDelegate
    let cont = appDele.persistentContainer.viewContext

    let ent  = TestEntity(context:cont)

But I got an error "use of unresolved identifier 'TestEntity'."

how to resolve that error. enter image description here enter image description here

like image 788
Raj Aggrawal Avatar asked Jan 17 '17 11:01

Raj Aggrawal


3 Answers

Product->Buld for testing solved this issue for me(it solves most unresolved identifier bugs for some strange reason)

like image 125
JP Aquino Avatar answered Nov 15 '22 21:11

JP Aquino


I solved it by changing import Foundation to import UIKit.

Because UIApplication isn't included in Foundation framework.

like image 40
Bright Avatar answered Nov 15 '22 20:11

Bright


"use of unresolved identifier 'TestEntity'."Means that you are trying to use a class/struct that is declared nowhere. Possibly you need to generate the NSManagedObjects for your entities.

enter image description here

like image 34
Giuseppe Lanza Avatar answered Nov 15 '22 19:11

Giuseppe Lanza