1
私はiOS
アプリでクリーンアーキテクチャを実装するために、this exampleに従っています。Swift 3 - 未解決の識別子「静的」の使用
class CreateOrderConfigurator
{
private static var __once:() = {
//ERROR - use of unresolved identifier 'Static'
Static.instance = CreateOrderConfigurator()
}()
// MARK: Object lifecycle
class var sharedInstance: CreateOrderConfigurator
{
struct Static {
static var instance: CreateOrderConfigurator?
static var token: Int = 0
}
_ = CreateOrderConfigurator.__once
return Static.instance!
}
// MARK: Configuration
func configure(_ viewController: CreateOrderViewController)
{
let router = CreateOrderRouter()
router.viewController = viewController
let presenter = CreateOrderPresenter()
presenter.output = viewController
let interactor = CreateOrderInteractor()
interactor.output = presenter
viewController.output = interactor
viewController.router = router
}
}
エラーはuse of unresolved identifier 'Static'
と表示されます。これをどうすれば解決できますか?
PS:私はシングルトンが
static let sharedInstance = CreateOrderConfigurator()
と
private static var __once:() = {
//ERROR - use of unresolved identifier 'Static'
Static.instance = CreateOrderConfigurator()
}()
// MARK: Object lifecycle
class var sharedInstance: CreateOrderConfigurator
{
struct Static {
static var instance: CreateOrderConfigurator?
static var token: Int = 0
}
_ = CreateOrderConfigurator.__once
return Static.instance!
}
を交換しスウィフト
に非常に簡単です