//
//  NSObject+SSAdd.swift
//  htcm_swift
//
//  Created by soldoros on 2018/12/21.
//  Copyright © 2018年 soldoros. All rights reserved.
//


import Foundation
import UIKit


extension NSObject{
    
    class func isEmpthStr(object:NSObject)->Bool{
        if(object.description == ""){
            return true
        }else{
            return false
        }
    }
    
    
    //适配不同的机型
    class func getNumber(i5:CGFloat, i6:CGFloat, iPlus:CGFloat, iPX:CGFloat)-> CGFloat{
        if(SCREEN_Width == 320){return i5}
        else if(SCREEN_Width == 375){return i6}
        else if(SCREEN_Width == 414){return iPlus}
        else if(SCREEN_Width == 812){return iPX}
        else {return i6}
    }
    
    
    
    
    ///发送不带参数的通知
   class func sendNotifCation(key:String){
        let nc:NotificationCenter = NotificationCenter.default
        let noti:NSNotification = NSNotification.init(name: NSNotification.Name(rawValue: key), object: nil)
        nc.post(noti as Notification)
    }
    
    ///发送带参数的通知 参数格式为键值对
    class func sendNotifCation(key:String,object:Any){
        let nc:NotificationCenter = NotificationCenter.default
        let noti:NSNotification = NSNotification.init(name: NSNotification.Name(rawValue: key), object: object)
        nc.post(noti as Notification)
    }
    
    //移除通知
    class func deleteNotifCation(){
        NotificationCenter.default.removeObserver(self)
    }
    
    
    
    
    //时间戳转时间 yyyy-MM-dd HH:mm:ss
    class func timeStampToString(timeStamp:String)->String {
        
        let time = Int(timeStamp)
        let timeSta:TimeInterval = TimeInterval(time! / 1000)
        let date = NSDate(timeIntervalSince1970: timeSta)
        let dfmatter = DateFormatter()
        
        dfmatter.dateFormat="yyyy.MM.dd"
        return dfmatter.string(from: date as Date)
    }
    
}
