Post not yet marked as solved
Post marked as unsolved with 5 replies, 2,622 views
We raised a bug on this, but just double checking we are not doing something silly, has anyone seen this?We set up a FetchRequest like this:@FetchRequest(entity: Activity.entity(),
sortDescriptors: [NSSortDescriptor(keyPath: \Activity.name, ascending: true)],
predicate: NSPredicate(value: true),
animation: .default) var test : FetchedResultsand then try to use it in a view:ForEach (test) { activity in
Text(activity.name)
}But get the following compile-time bug:*** Value of type 'ServerObject' has no member 'name'Now the type of the entity is "Activity" defined as:@objc(Activity)
public class Activity: ControlledResource {
...
@objc(ControlledResource)
public class ControlledResource: ServerObject {
...
@objc(ServerObject)
publicclass ServerObject: NSManagedObject, Identifiable {And "Actifvity" definitely has "name", this is an existing app and core data model being migrated to swiftui. "name" works in the original code.But it seems from the compiler error that the compiler thinks its the superclass type (ServerObject) being returned which does NOT have "name".Is it possible the compiler is looking for the "Identifiable" conformant super class and not correctly working out the explicit subclass type is actually the object being fetched?