session-ios/Session/Signal/ExperienceUpgrade.swift

77 lines
3 KiB
Swift
Raw Normal View History

//
2018-05-25 22:51:40 +02:00
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
2020-11-11 07:45:50 +01:00
import SignalUtilitiesKit
import SignalUtilitiesKit
2018-05-25 22:51:40 +02:00
@objc public class ExperienceUpgrade: TSYapDatabaseObject {
let title: String
let body: String
let image: UIImage?
2018-05-25 22:51:40 +02:00
@objc public required init(uniqueId: String, title: String, body: String, image: UIImage) {
self.title = title
self.body = body
self.image = image
super.init(uniqueId: uniqueId)
}
2018-10-17 00:16:19 +02:00
@objc
public override init() {
// This is the unfortunate seam between strict swift and fast-and-loose objc
// we can't leave these properties nil, since we really "don't know" that the superclass
// will assign them.
self.title = "New Feature"
self.body = "Bug fixes and performance improvements."
self.image = nil
super.init()
}
2018-05-25 22:51:40 +02:00
@objc public override required init(uniqueId: String?) {
// This is the unfortunate seam between strict swift and fast-and-loose objc
// we can't leave these properties nil, since we really "don't know" that the superclass
// will assign them.
self.title = "New Feature"
self.body = "Bug fixes and performance improvements."
self.image = nil
super.init(uniqueId: uniqueId)
}
2018-05-25 22:51:40 +02:00
@objc public required init!(coder: NSCoder) {
// This is the unfortunate seam between strict swift and fast-and-loose objc
// we can't leave these properties nil, since we really "don't know" that the superclass
// will assign them.
self.title = "New Feature"
self.body = "Bug fixes and performance improvements."
self.image = nil
super.init(coder: coder)
}
2020-06-05 05:43:06 +02:00
@objc public required init(dictionary dictionaryValue: [String: Any]!) throws {
// This is the unfortunate seam between strict swift and fast-and-loose objc
// we can't leave these properties nil, since we really "don't know" that the superclass
// will assign them.
self.title = "New Feature"
self.body = "Bug fixes and performance improvements."
self.image = nil
try super.init(dictionary: dictionaryValue)
}
2018-05-25 22:51:40 +02:00
@objc public override class func storageBehaviorForProperty(withKey propertyKey: String) -> MTLPropertyStorage {
// These exist in a hardcoded set - no need to save them, plus it allows us to
// update copy/image down the line if there was a typo and we want to re-expose
// these models in a "change log" archive.
if propertyKey == "title" || propertyKey == "body" || propertyKey == "image" {
return MTLPropertyStorageNone
} else if propertyKey == "uniqueId" || propertyKey == "seenAt" {
return super.storageBehaviorForProperty(withKey: propertyKey)
} else {
// Being conservative here in case we rename a property.
2018-08-27 16:27:48 +02:00
owsFailDebug("unknown property \(propertyKey)")
return super.storageBehaviorForProperty(withKey: propertyKey)
}
}
}