swift的一些用法

var ad: AppDelegate! //or var ad: AppDelegate?

  var context: NSManagedObjectContext!    //or var context: NSManagedObjectContext?

  DispatchQueue.main.async(execute: {

      // Handle further UI related operations here....

      ad = UIApplication.shared.delegate as! AppDelegate

      context = ad.persistentContainer.viewContext 

      //or

      //self.ad = UIApplication.shared.delegate as! AppDelegate

      //self.context = ad.persistentContainer.viewContext 

    })

你可能感兴趣的:(swift的一些用法)