|
@@ -131,14 +131,14 @@ public func kf_imageCacheImage(originUrl: String, completeHandle: @escaping (_ i
|
|
|
}
|
|
|
|
|
|
/** 打印 */
|
|
|
-public func BFLog<T>(message : T) {
|
|
|
+public func BFLog<T>(message: T) {
|
|
|
// if PQBFConfig.shared.enableBFLog {
|
|
|
- let logger = NXLogger.shared
|
|
|
+ let logger = NXLogger.shared
|
|
|
|
|
|
- logger.level = .info
|
|
|
- logger.ouput = .debuggerConsole
|
|
|
+ logger.level = .info
|
|
|
+ logger.ouput = .debuggerConsole
|
|
|
|
|
|
- logger.d(message as? String ?? "")
|
|
|
+ logger.d(message as? String ?? "")
|
|
|
// } else {
|
|
|
// BuglyLog.level(.warn, logs: message as? String)
|
|
|
// }
|
|
@@ -282,8 +282,11 @@ public func dictionaryToJsonString(_ dic: [String: Any]) -> String? {
|
|
|
// MARK: 字符串转字典
|
|
|
|
|
|
public func jsonStringToDictionary(_ str: String) -> [String: Any]? {
|
|
|
+ if str.count <= 0 {
|
|
|
+ return [:]
|
|
|
+ }
|
|
|
let data = str.data(using: String.Encoding.utf8)
|
|
|
- if data == nil {
|
|
|
+ if data == nil || (data?.count ?? 0) <= 0 {
|
|
|
return [:]
|
|
|
}
|
|
|
if let dict = try? JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as? [String: Any] {
|
|
@@ -335,10 +338,10 @@ public func jsonStringToArray(jsonString: String) -> [Any]? {
|
|
|
/// - font: <#font description#>
|
|
|
/// - size: <#size description#>
|
|
|
/// - Returns: <#description#>
|
|
|
-public func sizeWithText(attributedText: NSMutableAttributedString? = nil,text: String, font: UIFont, size: CGSize) -> CGSize {
|
|
|
+public func sizeWithText(attributedText: NSMutableAttributedString? = nil, text: String, font: UIFont, size: CGSize) -> CGSize {
|
|
|
let option = NSStringDrawingOptions.usesLineFragmentOrigin
|
|
|
if attributedText != nil {
|
|
|
- let rect: CGRect = attributedText?.boundingRect(with: size, options: option, context: nil) ?? CGRect.init(origin: CGPoint.zero, size: size)
|
|
|
+ let rect: CGRect = attributedText?.boundingRect(with: size, options: option, context: nil) ?? CGRect(origin: CGPoint.zero, size: size)
|
|
|
return rect.size
|
|
|
} else {
|
|
|
let attributes = [NSAttributedString.Key.font: font]
|
|
@@ -702,9 +705,9 @@ public func updateTimeToCurrenTime(timeInterval: TimeInterval) -> String {
|
|
|
let dfmatter = DateFormatter()
|
|
|
// yyyy-MM-dd HH:mm:ss
|
|
|
dfmatter.dateFormat = "yyyy年M月d日 HH:mm"
|
|
|
-
|
|
|
+
|
|
|
var dfmatterStr = dfmatter.string(from: date as Date)
|
|
|
-
|
|
|
+
|
|
|
let currentDF = DateFormatter()
|
|
|
// yyyy-MM-dd HH:mm:ss
|
|
|
currentDF.dateFormat = "yyyy"
|