// // Poll.swift // ComposeUI // // Created by Shadowfacts on 4/22/23. // import CoreData @objc public class Poll: NSManagedObject { @NSManaged public var duration: TimeInterval @NSManaged public var multiple: Bool @NSManaged public var draft: Draft @NSManaged public var options: NSMutableOrderedSet init(context: NSManagedObjectContext) { super.init(entity: context.persistentStoreCoordinator!.managedObjectModel.entitiesByName["Poll"]!, insertInto: context) self.multiple = false self.duration = 24 * 60 * 60 // 1 day self.options = [ PollOption(context: context), PollOption(context: context), ] } public var pollOptions: [PollOption] { get { options.array as! [PollOption] } set { options = NSMutableOrderedSet(array: newValue) } } } extension Poll { public var hasContent: Bool { pollOptions.allSatisfy { !$0.text.isEmpty } } }