Ios 永远记住财产
我想将库添加到我的应用程序中,我们可以在文档中阅读:Ios 永远记住财产,ios,swift,Ios,Swift,我想将库添加到我的应用程序中,我们可以在文档中阅读: //declare this property where it won't go out of scope relative to your listener let reachability = try! Reachability() 所以,我所做的是: 创建Singleton对象以执行以下操作: class ReachabilityService { static let shared = ReachabilityService(
//declare this property where it won't go out of scope relative to your listener
let reachability = try! Reachability()
所以,我所做的是:
创建Singleton对象以执行以下操作:
class ReachabilityService {
static let shared = ReachabilityService()
private init() {}
private let reachability = try! Reachability()
}
是否将属性添加到AppDelegate以在应用程序生命周期内将其保留在内存中:
class AppDelegate: UIResponder, UIApplicationDelegate {
let reachability = ReachabilityService.shared
}
我的问题是,AppDelegate中的可访问性属性是否在应用程序的整个生命周期内都在内存中?是的,AppDelegate中声明的属性将在应用程序的整个生命周期内可用