Posts

Post not yet marked as solved
0 Replies
244 Views
I would like an NSManagedObject class to comply with a protocol that I have defined in Swift.The protocol defines only a number of properties that the NSManagedObject should have:@objc public protocol PLCNetworkUnit { var objectID: NSManagedObjectID { get } var type: NSNumber { get } var url: String { get } var port: NSNumber { get } var wifiPort: NSNumber { get } var wifiSSID: String { get } var wifiUrl: String { get } var modbusOffset: NSNumber { get } }For the most part, this works, but the compiler complains with the following warning:'copy' attribute on property 'modbusOffset' does not match the property inherited from 'PLCNetworkUnit'This is the definition of the NSManagedObject class:@interface SPSStation (CoreDataProperties) <PLCNetworkUnit> + (NSFetchRequest<SPSStation *> *)fetchRequest; @property (nullable, nonatomic, copy) NSNumber *activeTimeSwitches; @property (nullable, nonatomic, copy) NSNumber *modbusOffset; @property (nullable, nonatomic, copy) NSString *name; @property (nullable, nonatomic, copy) NSNumber *port; @property (nullable, nonatomic, copy) NSNumber *type; @property (nullable, nonatomic, copy) NSString *url; @property (nullable, nonatomic, copy) NSNumber *wifiPort; @property (nullable, nonatomic, copy) NSString *wifiSSID; @property (nullable, nonatomic, copy) NSString *wifiUrl; @property (nullable, nonatomic, retain) NSSet<Gear *> *gears; @property (nullable, nonatomic, retain) DatabaseProfile *profile; @property (nullable, nonatomic, retain) NSSet<Program *> *programs; @property (nullable, nonatomic, retain) NSSet<Sensor *> *sensor; @property (nullable, nonatomic, retain) NSSet<SystemValue *> *systemValues; @property (nullable, nonatomic, retain) NSSet<TimeSwitch *> *timer; @endHow do I get the NSManagedObject-based class to comply with the Swift protocol without the compiler complaining?
Posted
by devfcr.
Last updated
.
Post not yet marked as solved
2 Replies
2.8k Views
For a new SwiftUI project (actually it's a new version of an existing app) I want to use an existing Core Data data model.I wonder if there is a way to include an existing Core Data based SQLite database into the project within the PreviewProvider so that I can work with existing data while designing the user interface.This would be much more convenient and less error-prone than handling mockup code.
Posted
by devfcr.
Last updated
.