Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 永远记住财产_Ios_Swift - Fatal编程技术网

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中声明的属性将在应用程序的整个生命周期内可用