EasySwiftUIKit
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- iOS 11
- Swift 5
- Xcode 12
Installation
EasySwiftUIKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'EasySwiftUIKit'
or
pod 'EasySwiftUIKit', '~> 1.0'
Integration In Project
import EasySwiftUIKit
Date Format in Swift
//stringDate.dateFormat(toFormat: "yyyy-MM-dd HH:mm:ss", withFormat: "MMM dd,yyyy")
//Return formatted date in string form
let date = "2021-03-28 12:24:26".dateFormat(toFormat: "yyyy-MM-dd HH:mm:ss", withFormat: "MMM dd,yyyy")
or
//stringDate.dateToString(toFormat: "yyyy-MM-dd HH:mm:ss", withFormat: "MMM dd,yyyy")
//Return formatted date in string form
let date = "2021-02-28 12:24:26".dateToString(toFormat: "yyyy-MM-dd HH:mm:ss", withFormat: "MMM dd,yyyy")
or
//stringDate.dateToDate(toFormat: "yyyy-MM-dd HH:mm:ss", withFormat: "MMM dd,yyyy")
//Return formatted date in date form
let date = "2021-02-28 12:24:26".dateToDate(toFormat: "yyyy-MM-dd HH:mm:ss", withFormat: "MMM dd,yyyy")
Parse JSON
let jsonResult = JSONParser.parseJSON(dataModel: [DataModel].self, jsonData: response)
switch jsonResult {
case .success(let result):
for item in result {
}
case .failure(let error):
print("Error: \(error)")
}
Quantum Value: Decode string or int value in structure
//Individual/single data model
let modelData = ModelData(name: "Rz Rasel", data: QuantumValue.string("Rashed - Uz - Zaman"))
//Usages of individual/single data model
let strValue = modelData.data.stringValue
or
//struct data model
struct ModelData: Decodable {
var name: String!
var data: QuantumValue!
}
//List of data model
let modelDataList = [
ModelData(name: "Rz Rasel", data: QuantumValue.int(1)),
ModelData(name: "Rz Rasel", data: QuantumValue.string("Rashed - Uz - Zaman"))
]
//Usages of list of data model
for item in modelDataList {
//Usages of QuantumValue data
let intVal = item.data.intValue
let strVal = item.data.stringValue
//Usages of QuantumValue data in data safety
let safeIntVal = item.data?.intValue
let safeStrVal = item.data?.stringValue
}
Author
Md. Rashed - Uz - Zaman (Rz Rasel)
License
EasySwiftUIKit is available under the MIT license. See the LICENSE file for more info.