forked from shadowfacts/Tusker
Fix crash when inserting poll from draft created in share sheet
This commit is contained in:
parent
3bba4edb45
commit
49334766ef
|
@ -16,16 +16,6 @@ public class Poll: NSManagedObject {
|
|||
@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]
|
||||
|
@ -35,6 +25,18 @@ public class Poll: NSManagedObject {
|
|||
}
|
||||
}
|
||||
|
||||
public override func awakeFromInsert() {
|
||||
super.awakeFromInsert()
|
||||
self.multiple = false
|
||||
self.duration = 24 * 60 * 60 // 1 day
|
||||
if let managedObjectContext {
|
||||
self.options = [
|
||||
PollOption(context: managedObjectContext),
|
||||
PollOption(context: managedObjectContext),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Poll {
|
||||
|
|
Loading…
Reference in New Issue