Commit 379704cb authored by David黄金龙's avatar David黄金龙

添加 分类方法

parent 759a4807
......@@ -19,6 +19,9 @@
04FAC5512B3ABA5000D24B36 /* YHLoginStyleButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FAC5502B3ABA5000D24B36 /* YHLoginStyleButton.swift */; };
04FAC5532B3AC6F200D24B36 /* YHLoginPrivacyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FAC5522B3AC6F200D24B36 /* YHLoginPrivacyView.swift */; };
6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; };
A5009DD82B3D72FD00168BB1 /* NetBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5009DD72B3D72FD00168BB1 /* NetBaseModel.swift */; };
A5009DDA2B3D858800168BB1 /* Dictionary+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5009DD92B3D858800168BB1 /* Dictionary+Extension.swift */; };
A5009DDC2B3D85B800168BB1 /* Array+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5009DDB2B3D85B800168BB1 /* Array+Extension.swift */; };
A52DF0BB2B330A20006618D6 /* YHAllApiName.swift in Sources */ = {isa = PBXBuildFile; fileRef = A52DEEAA2B330A1F006618D6 /* YHAllApiName.swift */; };
A52DF0BC2B330A20006618D6 /* YHNetworkStatusManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A52DEEAB2B330A1F006618D6 /* YHNetworkStatusManager.swift */; };
A52DF0BD2B330A20006618D6 /* YHBaseUrlManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A52DEEAC2B330A1F006618D6 /* YHBaseUrlManager.swift */; };
......@@ -94,6 +97,9 @@
04FAC5522B3AC6F200D24B36 /* YHLoginPrivacyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLoginPrivacyView.swift; sourceTree = "<group>"; };
58C2405158A4A6632D0E7460 /* Pods-galaxy.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.debug.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.debug.xcconfig"; sourceTree = "<group>"; };
987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_galaxy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A5009DD72B3D72FD00168BB1 /* NetBaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetBaseModel.swift; sourceTree = "<group>"; };
A5009DD92B3D858800168BB1 /* Dictionary+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Dictionary+Extension.swift"; sourceTree = "<group>"; };
A5009DDB2B3D85B800168BB1 /* Array+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Extension.swift"; sourceTree = "<group>"; };
A52DEEAA2B330A1F006618D6 /* YHAllApiName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHAllApiName.swift; sourceTree = "<group>"; };
A52DEEAB2B330A1F006618D6 /* YHNetworkStatusManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHNetworkStatusManager.swift; sourceTree = "<group>"; };
A52DEEAC2B330A1F006618D6 /* YHBaseUrlManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHBaseUrlManager.swift; sourceTree = "<group>"; };
......@@ -330,6 +336,7 @@
A52DEEAA2B330A1F006618D6 /* YHAllApiName.swift */,
A52DEEAB2B330A1F006618D6 /* YHNetworkStatusManager.swift */,
A52DEEAC2B330A1F006618D6 /* YHBaseUrlManager.swift */,
A5009DD72B3D72FD00168BB1 /* NetBaseModel.swift */,
);
path = NetWork;
sourceTree = "<group>";
......@@ -348,6 +355,8 @@
A52DEEBD2B330A1F006618D6 /* UIImage+Extension.swift */,
A52DEEC02B330A1F006618D6 /* String+Extension.swift */,
A52DEEC12B330A1F006618D6 /* UILable+Extension.swift */,
A5009DD92B3D858800168BB1 /* Dictionary+Extension.swift */,
A5009DDB2B3D85B800168BB1 /* Array+Extension.swift */,
);
path = Extention;
sourceTree = "<group>";
......@@ -695,13 +704,16 @@
A52DF0C32B330A20006618D6 /* YhCacheTool.swift in Sources */,
A52DF24A2B33177F006618D6 /* BsHUDContainerView.swift in Sources */,
A52DF0BD2B330A20006618D6 /* YHBaseUrlManager.swift in Sources */,
A5009DD82B3D72FD00168BB1 /* NetBaseModel.swift in Sources */,
04FAC54D2B3A9E3D00D24B36 /* YHConfig.swift in Sources */,
04F526C82B3BB94200FC6CE6 /* YHSMSCodeView.m in Sources */,
04F526AF2B32D4B600FC6CE6 /* YHPersonalCenterCell.swift in Sources */,
A5009DDA2B3D858800168BB1 /* Dictionary+Extension.swift in Sources */,
A52DF23B2B330A21006618D6 /* YHNoDataTipView.swift in Sources */,
A52DF23F2B3316A0006618D6 /* YHBasicContentView.swift in Sources */,
A52DF0C42B330A20006618D6 /* UIApplication+Extension.swift in Sources */,
A52DF0C72B330A20006618D6 /* UIFont+Extension.swift in Sources */,
A5009DDC2B3D85B800168BB1 /* Array+Extension.swift in Sources */,
A52DF24E2B33177F006618D6 /* BsHUDSuccessView.swift in Sources */,
A52DF0CC2B330A20006618D6 /* UIImage+Extension.swift in Sources */,
A52DF24F2B33177F006618D6 /* BsHUDProgressView.swift in Sources */,
......
//
// Array+Extension.swift
// galaxy
//
// Created by davidhuangA on 2023/12/28.
// Copyright © 2023 www.davidhuang.com. All rights reserved.
//
import Foundation
extension Array {
/// 数组转json字符串
func yh_toJSONString() -> String? {
if (!JSONSerialization.isValidJSONObject(self)) {
return nil
}
do {
let data = try JSONSerialization.data(withJSONObject: self, options: [])
let json = String(data: data, encoding: String.Encoding.utf8)
return json
} catch {
return nil
}
}
}
//
// Dictionary+Extension.swift
// galaxy
//
// Created by davidhuangA on 2023/12/28.
// Copyright © 2023 www.davidhuang.com. All rights reserved.
//
import Foundation
extension Dictionary {
/// 字典转Json字符串
func yh_toJSONString() -> String? {
if (!JSONSerialization.isValidJSONObject(self)) {
print("无法解析出JSONString")
return nil
}
do {
let data = try JSONSerialization.data(withJSONObject: self, options: [])
let json = String(data: data, encoding: String.Encoding.utf8)
return json
} catch {
return nil
}
}
}
......@@ -7,6 +7,30 @@
//
import UIKit
extension String {
/// JSONString转换为字典
func toDictionary() -> Dictionary<String, Any>? {
guard let jsonData:Data = data(using: .utf8) else { return nil }
if let dict = try? JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers) {
if let temp = dict as? Dictionary<String, Any> {
return temp
}
}
return nil
}
/// JSONString转换为数组
func toArray() -> Array<Any>? {
guard let jsonData:Data = data(using: .utf8) else { return nil }
if let array = try? JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers) {
if let temp = array as? Array<Any> {
return temp
}
}
return nil
}
}
extension String {
// MARK: - 拨打电话
......
//
// NetBaseModel.swift
// galaxy
//
// Created by davidhuangA on 2023/12/28.
// Copyright © 2023 www.davidhuang.com. All rights reserved.
//
import Foundation
import SmartCodable
struct NetBaseModel: SmartCodable {
var data : SmartAny?
var errorCode : Int?
var errorMessage : String?
var success : Bool?
init() { }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment