{
"data" : {
"param" : "hoge"
}
}{| import Foundation | |
| import Firebase | |
| typealias FIRParamters = [String : NSObject] | |
| protocol EventReportType { | |
| var name: String { get } | |
| var parameters: FIRParamters? { get } | |
| func sendLog() | |
| } |
| protocol HogeType { | |
| init(value: String) | |
| } | |
| final class HogeClass { //finalにしておけば | |
| var value = "" | |
| var value2 = "" | |
| required public init(value: String, value2: String) { | |
| self.value = value |
| enum Sometype<T: SomeProtocol> { | |
| case one | |
| case two | |
| case three | |
| associatedtype Associated { | |
| switch { | |
| case .one: return One.self | |
| case .two: return Two.self |
| //見た目は同じInitializer。単数か複数かは気にする必要なし。勝手にsingleかmultipleに振り分けてくれる。 | |
| enum PossibleArrayType<T> { | |
| case single(T) | |
| case multiple([T]) | |
| init(_ single: T) { | |
| self = .single(single) | |
| } | |
| init(_ multiple([T]) { |
{
"data" : {
"param" : "hoge"
}
}{| import UIKit | |
| //でもこれだと、styleの指定ができないので、3つのタプルにしてみた | |
| private func showAlert(title: String, message: String, actions: [(String, UIAlertActionStyle, ((UIAlertAction) -> Void)?)]) { | |
| let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
| actions.forEach { | |
| let action = UIAlertAction(title: $0, style: $1, handler: $2) | |
| alertController.addAction(action) | |
| } |
より良くするために考えたいのが、 これだと
case .division:
if secondValue != 0 {
value = firstValue / secondValue
}| import Foundation | |
| import AVFoundation | |
| public enum AVMetadataObjectType { | |
| case UPCECode | |
| case Code39Code | |
| case Code39Mod43Code | |
| case EAN13Code | |
| case EAN8Code | |
| case Code93Code |