要调用AppDelegate中的saveTotalCount方法,您可以按照以下步骤进行操作:

  1. 打开AppDelegate.swift文件。
  2. 在类定义中找到saveTotalCount方法的实现。
  3. 确保saveTotalCount方法是公开的(即使用public关键字进行修饰),否则无法在其他类中访问它。
  4. 在您需要调用saveTotalCount方法的地方,使用以下代码来获取AppDelegate实例并调用saveTotalCount方法:
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
    appDelegate.saveTotalCount()
}

请注意,上述代码假设您已经在AppDelegate中定义了saveTotalCount方法,并且您正在使用默认的AppDelegate类。如果您已经自定义了AppDelegate类,请相应地更改代码中的类名。

ios swift 调用AppDelegate saveTotalCount方法

原文地址: http://www.cveoy.top/t/topic/jbsF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录