3
votes

How do I use @FetchRequest with a CoreData entity Post that has Codegen: Class Def. set in Xcode? So I don't create the Post" entity class manually, but let Xcode generate it?

I now get a

Use of undeclared type Post

as an error on the last line.

@FetchRequest(entity: Post.entity(), sortDescriptors: [ 
    NSSortDescriptor(keyPath: \Post.date, ascending: true)
]) 
var posts: FetchedResults<Post> // Use of undeclared type ´Post´

xcdatamodel

1
This looks fine. Can you share the entity, Post definition?Pankaj Kulkarni
@PankajKulkarni updated with a screenshot of the xcdatamodelEhsan
Have you found a solution?Krakke93
No, unfortunately not. Since it's a hobby project I've put it on ice at the moment.Ehsan

1 Answers

5
votes

Core data can be buggy sometimes. Try quitting Xcode and reopening it again.