You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.0 KiB
29 lines
1.0 KiB
//
|
|
// Alert.swift
|
|
// cloudmusic
|
|
//
|
|
// Created by Qihua Pan on 2020/7/3.
|
|
// Copyright © 2020 Qihua Pan. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import CoreData
|
|
extension UIViewController{
|
|
func alert(message:String,title:String="警告信息",preferredStyle:UIAlertController.Style=UIAlertController.Style.alert,style:UIAlertAction.Style=UIAlertAction.Style.destructive){
|
|
let alertController = UIAlertController(title: title, message: message, preferredStyle: preferredStyle)
|
|
|
|
alertController.addAction(UIAlertAction(title: "确认", style:style, handler: nil))
|
|
|
|
self.present(alertController, animated: true, completion: nil)
|
|
}
|
|
|
|
//获取上下文对象
|
|
func getContext()-> NSManagedObjectContext {
|
|
//获取总代理
|
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
//获取托管对象总管
|
|
//let managedObjectContect = appDelegate.persistentContainer.viewContext
|
|
//返回托管对象总管
|
|
return appDelegate.persistentContainer.viewContext
|
|
}
|
|
}
|
|
|