记录不平常使用的系统键盘音效ID:
- 按Click – ID:
1123
- 按删除 – ID:
1155
- 确定—ID:
1156
协议扩展
protocol ShakeProtocol{
var name:String { get set }
func shakeScreen()
}
extension ShakeProtocol where Self:UIControl{
func shakeScreen(){
print("123---\(self.classForCoder)")
}
}
String 计算MD5
extension String{
var md5: String {
let dataInput = self.cString(using: .utf8)!
let dataLen = CUnsignedInt(self.lengthOfBytes(using: .utf8))
let digestLen = Int(CC_MD5_DIGEST_LENGTH)
let result = UnsafeMutablePointer<CUnsignedChar>.allocate(capacity: digestLen)
CC_MD5(dataInput, dataLen, result)
var hash = ""
for item in 0..<digestLen {
hash += String(format:"%02X", result[item])
}
result.deinitialize(count: digestLen)
return hash
}
}
系统日历、提醒写入(EventKit)